Advertisement
Guest User

Untitled

a guest
Nov 15th, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.11 KB | None | 0 0
  1. namespace AutoCompletarTextBox{
  2.  
  3. public partial class frmLogin : Form
  4. {
  5. public frmLogin()
  6. {
  7. InitializeComponent();
  8. lblHora.Text = DateTime.Now.ToString();
  9. }
  10.  
  11. public static String Codigo = "";
  12.  
  13. private void timer1_Tick(object sender, EventArgs e)
  14. {
  15. lblHora.Text = DateTime.Now.ToString();
  16. }
  17.  
  18. private void btnExit_Click(object sender, EventArgs e)
  19. {
  20. if (MessageBox.Show("Do you really want to exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
  21. {
  22. this.Close();
  23. }
  24. }
  25.  
  26. private void btnIngresar_Click(object sender, EventArgs e)
  27. {
  28. try
  29. {
  30. string CMD = string.Format("select * from Usuarios where Username='{0}' and Password= '{1}'", txtUser.Text.Trim(), txtPass.Text.Trim());
  31. DataSet ds = Utilidades.Ejecutar(CMD);
  32. Codigo = ds.Tables[0].Rows[0]["id_usuario"].ToString().Trim();
  33. string cuenta = ds.Tables[0].Rows[0]["Username"].ToString().Trim();
  34. string contra = ds.Tables[0].Rows[0]["Password"].ToString().Trim();
  35.  
  36. if (cuenta == txtUser.Text.Trim() && contra == txtPass.Text.Trim())
  37. {
  38. if (Convert.ToBoolean(ds.Tables[0].Rows[0]["Status_admin"]) == true)
  39. {
  40. frmMainMenuADMIN Mmenu = new frmMainMenuADMIN();
  41. this.Hide();
  42. Mmenu.Show();
  43. }
  44. else
  45. {
  46. frmMainMenuUSER Mmenu2 = new frmMainMenuUSER();
  47. this.Hide();
  48. Mmenu2.Show();
  49. }
  50. }
  51. }
  52. catch (Exception)
  53. {
  54. MessageBox.Show("Username/Password are incorrect.");
  55. }
  56. }
  57.  
  58. private void frmLogin_FormClosed(object sender, FormClosedEventArgs e)
  59. {
  60. Application.Exit();
  61. }
  62.  
  63. private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  64. {
  65. frmPassChange pc = new frmPassChange();
  66. pc.Show();
  67. }
  68. }}
  69.  
  70. namespace AutoCompletarTextBox
  71. {
  72. public partial class frmNuevaCaptura : Form
  73. {
  74. SqlConnection conexion = new SqlConnection(@"DataSource= CP-PC; Initial Catalog= SisIndustrial; Integrated Security=true");
  75.  
  76. public frmNuevaCaptura()
  77. {
  78. InitializeComponent();
  79. }
  80.  
  81.  
  82. private void frmNuevaCaptura_Load(object sender, EventArgs e)
  83. {
  84. Conexion c = new Conexion();
  85. c.autoCompletar(textBox1);
  86.  
  87. DateTime dt = DateTime.Now;
  88. CultureInfo ci = new CultureInfo("de-DE");
  89. string fecha1 = dt.ToString("d", ci);
  90.  
  91. String format = "MM/dd/yyyy hh:mm tt";
  92.  
  93. // Converts the local DateTime to a string
  94. // using the custom format string and display.
  95. String str = dt.ToString(format);
  96.  
  97. lblShowTime.Text = str;
  98. }
  99.  
  100. private void btnNuevoPN_Click(object sender, EventArgs e)
  101. {
  102. conexion.Open();
  103. SqlCommand cmd = conexion.CreateCommand();
  104. cmd.CommandType = CommandType.Text;
  105. cmd.CommandText = "insert into Num_Parte (Part_Number) values ('" + txtArea.Text.TrimEnd() + "')";
  106. cmd.ExecuteNonQuery();
  107. conexion.Close();
  108. MessageBox.Show("Visteon Part Number added successfully to the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
  109. }
  110.  
  111. private void btnGuardar_Click(object sender, EventArgs e)
  112. {
  113. if (txtArea.Text.TrimEnd() == "" || txtTipo.Text.TrimEnd() == "" || txtCliente.Text.TrimEnd() == "" || txtFamilia.Text.TrimEnd() == "" || txtProd.Text.TrimEnd() == "" || textBox1.Text.TrimEnd() == "" || txtoperador.Text.TrimEnd() == "" || txtTC.Text.TrimEnd() == "" || txtEFF.Text.TrimEnd() == "")
  114. {
  115. MessageBox.Show("Please fill all the fields to continue.","Atention", MessageBoxButtons.OK, MessageBoxIcon.Hand);
  116. }
  117.  
  118. if (txtArea.Text == "")
  119. {
  120. errorProvider1.SetError(txtArea, "Add the area.");
  121. }
  122.  
  123. if (txtTipo.Text == "")
  124. {
  125. errorProvider1.SetError(txtTipo, "Add a product type.");
  126. }
  127.  
  128. if (txtCliente.Text == "")
  129. {
  130. errorProvider1.SetError(txtCliente, "Add a customer.");
  131. }
  132.  
  133. if (txtFamilia.Text == "")
  134. {
  135. errorProvider1.SetError(txtFamilia, "Add a family.");
  136. }
  137.  
  138. if (txtProd.Text == "")
  139. {
  140. errorProvider1.SetError(txtProd, "Add a Production Line.");
  141. }
  142.  
  143. if (textBox1.Text == "")
  144. {
  145. errorProvider1.SetError(textBox1, "Add a VPN.");
  146. }
  147.  
  148. if (txtoperador.Text == "")
  149. {
  150. errorProvider1.SetError(txtoperador, "Add the quantity.");
  151. }
  152.  
  153. if (txtTC.Text == "")
  154. {
  155. errorProvider1.SetError(txtTC, "Add the CT.");
  156. }
  157.  
  158. if (txtEFF.Text == "")
  159. {
  160. errorProvider1.SetError(txtEFF, "Add the eff.");
  161. }
  162.  
  163.  
  164. else
  165. {
  166. conexion.Open();
  167. SqlCommand cmd = conexion.CreateCommand();
  168. cmd.CommandType = CommandType.Text;
  169. cmd.CommandText = "insert into CWS (Area, Product_Type, Customer, Family, Production_Line, Part_Number, Quantity_Operators, Cycle_Time, Rate, Cws) values ('" + txtArea.Text.TrimEnd() + "', '" + txtTipo.Text.TrimEnd() + "' , '" + txtCliente.Text.TrimEnd() + "', '" + txtFamilia.Text.TrimEnd() + "', '" + txtProd.Text.TrimEnd() + "', '" + textBox1.Text.TrimEnd() + "', '" + txtoperador.Text.TrimEnd() + "', '" + txtTC.Text.TrimEnd() + "', '" + txtResultado.Text.TrimEnd() + "', '" + txtResultadoCWS.Text.TrimEnd() + "', )";
  170. cmd.ExecuteNonQuery();
  171. conexion.Close();
  172. DialogResult dialogResult = MessageBox.Show("New capture was added!", "Atention", MessageBoxButtons.OK, MessageBoxIcon.Information);
  173.  
  174. }
  175. }
  176.  
  177.  
  178.  
  179. private void btnSaveArea_Click(object sender, EventArgs e)
  180. {
  181. conexion.Open();
  182. SqlCommand cmd = conexion.CreateCommand();
  183. cmd.CommandType = CommandType.Text;
  184. cmd.CommandText = "insert into Area (Nombre) values ('" + txtArea.Text.TrimEnd() + "')";
  185. cmd.ExecuteNonQuery();
  186. conexion.Close();
  187. MessageBox.Show("Area added succesfully to the database.");
  188. }
  189.  
  190. private void btnSaveType_Click(object sender, EventArgs e)
  191. {
  192. conexion.Open();
  193. SqlCommand cmd = conexion.CreateCommand();
  194. cmd.CommandType = CommandType.Text;
  195. cmd.CommandText = "insert into Tipo_Producto (Tipo) values ('" + txtProd.Text.TrimEnd() + "')";
  196. cmd.ExecuteNonQuery();
  197. conexion.Close();
  198. MessageBox.Show("Product type was added succesfully to the database.");
  199. }
  200.  
  201. private void btnCalcular3_Click(object sender, EventArgs e)
  202. {
  203. int fijo = int.Parse(lblfijo.Text); //3600
  204. int tc = int.Parse(txtTC.Text);
  205. int rph = fijo / tc; //3600/tc= rate/hra (rph)
  206. txtResultado.Text = rph.ToString(); //el resultado que es un Rate/hora se almacenara en txtResultado [1]
  207.  
  208. decimal eff = decimal.Parse(txtEFF.Text);
  209. int fijo2 = int.Parse(lblfijo2.Text); // /100
  210. decimal resp = eff / fijo2;
  211. lblresul.Text = resp.ToString();
  212.  
  213. int resul1 = rph;
  214. decimal num2 = decimal.Parse(lblresul.Text);
  215. decimal reff = resul1 * num2;
  216. txtResultado2.Text = reff.ToString(); //el resultado, qe es un Rate con EFF, se almacenara en txtResultado2 [3]
  217.  
  218. decimal operador = decimal.Parse(txtoperador.Text);
  219. decimal resul2 = reff;
  220. decimal div2 = operador / resul2; // cantidad de op / rate con eff = new CWS con EFF
  221. txtResultadoCWSEFF.Text = div2.ToString(); // el resultado, que es NEW CWS CON EFF, se almacenara en [4]
  222.  
  223. decimal operador2 = decimal.Parse(txtoperador.Text);
  224. decimal rph2 = rph;
  225. decimal div3 = operador2 / rph2; // cantidad de op / Resultado1 = CWS normal
  226. txtResultadoCWS.Text = div3.ToString(); // el resultado, que es el CWS, se almacena en [1]
  227. }
  228.  
  229. private void btnSaveCustomer_Click(object sender, EventArgs e)
  230. {
  231. conexion.Open();
  232. SqlCommand cmd = conexion.CreateCommand();
  233. cmd.CommandType = CommandType.Text;
  234. cmd.CommandText = "insert into Cliente values ('" + txtCliente.Text.TrimEnd() + "')";
  235. cmd.ExecuteNonQuery();
  236. conexion.Close();
  237. MessageBox.Show("Customer added succesfully to the database.");
  238. }
  239.  
  240. private void btnSaveFam_Click(object sender, EventArgs e)
  241. {
  242. conexion.Open();
  243. SqlCommand cmd = conexion.CreateCommand();
  244. cmd.CommandType = CommandType.Text;
  245. cmd.CommandText = "insert into Familia (Descripcion_Linea) values ('" + txtFamilia.Text.TrimEnd() + "')";
  246. cmd.ExecuteNonQuery();
  247. conexion.Close();
  248. MessageBox.Show("Family added succesfully to the database.");
  249. }
  250.  
  251. private void btnSaveProdLine_Click(object sender, EventArgs e)
  252. {
  253. conexion.Open();
  254. SqlCommand cmd = conexion.CreateCommand();
  255. cmd.CommandType = CommandType.Text;
  256. cmd.CommandText = "insert into Producto (Descripcion_Subproducto) values ('" + txtProd.Text.TrimEnd() + "')";
  257. cmd.ExecuteNonQuery();
  258. conexion.Close();
  259. MessageBox.Show("Production line was added succesfully to the database.");
  260. }
  261.  
  262.  
  263.  
  264. private void button1_Click(object sender, EventArgs e)
  265. {
  266. txtArea.Clear();
  267. txtTipo.Clear();
  268. txtCliente.Clear();
  269. txtFamilia.Clear();
  270. txtProd.Clear();
  271. textBox1.Clear();
  272. txtoperador.Clear();
  273. txtTC.Clear();
  274. txtResultado.Clear();
  275. txtResultado2.Clear();
  276. txtResultadoCWS.Clear();
  277. txtResultadoCWSEFF.Clear();
  278. }
  279.  
  280. private void txtoperador_KeyPress(object sender, KeyPressEventArgs e)
  281. {
  282. char ch = e.KeyChar;
  283.  
  284. if (!Char.IsDigit(ch) && ch != 8)
  285. {
  286. e.Handled = true;
  287. }
  288. }
  289.  
  290. private void txtTC_KeyPress(object sender, KeyPressEventArgs e)
  291. {
  292. char ch = e.KeyChar;
  293.  
  294. if (!Char.IsDigit(ch) && ch != 8)
  295. {
  296. e.Handled = true;
  297. }
  298. }
  299.  
  300.  
  301.  
  302. private void txtResultadoCWS_TextChanged(object sender, EventArgs e)
  303. {
  304. string v1 = txtEFF.Text;
  305. decimal v2 = Convert.ToDecimal(v1);
  306. }
  307.  
  308. private void btnVer_Click(object sender, EventArgs e)
  309. {
  310. frmCWSTable cws = new frmCWSTable();
  311. cws.Show();
  312. }
  313.  
  314. public partial class frmMainMenuADMIN : Form
  315. {
  316. public frmMainMenuADMIN()
  317. {
  318. InitializeComponent();
  319. }
  320.  
  321. private void exitToolStripMenuItem_Click(object sender, EventArgs e)
  322. {
  323. if (MessageBox.Show("Do you really want to exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
  324. {
  325. this.Close();
  326. }
  327. }
  328.  
  329. private void perfilToolStripMenuItem_Click(object sender, EventArgs e)
  330. {
  331. VentanaAdmin VenAdm = new VentanaAdmin();
  332. VenAdm.Show();
  333. }
  334.  
  335. private void nuevaCapturaBWSToolStripMenuItem_Click(object sender, EventArgs e)
  336. {
  337. frmNuevaCaptura NuevaCap = new frmNuevaCaptura();
  338. NuevaCap.Show();
  339. }
  340. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement