Advertisement
Guest User

Untitled

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