public InjectionMachine getByID(string _id)
        {
            InjectionMachine injectionMachine = null;
            try
            {
                conn = db.openConn();
                sb = new StringBuilder();
                sb.Remove(0, sb.Length);
                sb.Append(" SELECT id,name,mold_no FROM injection_machines ");
                sb.Append(" WHERE id='" + _id + "'");

                string sql;
                sql = sb.ToString();
                comm = new SqlCommand();
                comm.CommandText = sql;
                comm.CommandType = CommandType.Text;
                comm.Connection = conn;
                dr = comm.ExecuteReader();
                if (dr.HasRows)
                {

                    DataTable dt = new DataTable();
                    dt.Load(dr);
                    foreach (DataRow drw in dt.Rows)
                    {
                        injectionMachine = new InjectionMachine();
                        injectionMachine.ID = Convert.ToInt32(drw["id"].ToString());
                        injectionMachine.Name = drw["name"].ToString();
                        injectionMachine.MoldNo = drw["mold_no"].ToString();

                    }
                }

            }
            catch (Exception ex)
            {
                dr.Close();
                conn.Close();
                return null;
                throw ex;

            }
            finally
            {
                conn.Close();
            }

            return injectionMachine;
        }
        private void cbomachine_SelectedValueChanged(object sender, EventArgs e)
        {
            if (cbomachine.Items.Count >0) {
                injectionMachine = machineService.getByID(cbomachine.SelectedValue.ToString());
                if (injectionMachine != null)
                {
                    lblmachine.Text = injectionMachine.MoldNo;
                    lblsharp.Text ="#";

                    //rev
                    List<InjectionCabinetNumber> injectionCabinetNumbers = injectionService.getInjectionAll(cbopart.Text.Trim(), cboComplete.Text.Trim(), cbomachine.SelectedValue.ToString());
                    if (injectionCabinetNumbers != null && injectionCabinetNumbers.Count > 0)
                    {
                        lblrevision.Text = injectionCabinetNumbers[0].Rev;
                    }
                    else {
                        lblrevision.Text = "";
                    }

                    // color
                    List<InjectionCabinetNumber> injectionCabinetNumbers2 = injectionService.getInjectionAll(cbopart.Text.Trim(), cboComplete.Text.Trim(), cbomachine.SelectedValue.ToString());
                    if (injectionCabinetNumbers != null && injectionCabinetNumbers.Count > 0) {
                        injectionColors = colorservice.getByID(injectionCabinetNumbers2[0].ColorID);
                        if (injectionColors != null )
                        {
                            lbocolor.Text = injectionColors.Name;
                        }
                        else {
                            lbocolor.Text = "";
                        }

                        // meterial
                        injectionMaterial = meterialService.getByID(injectionCabinetNumbers2[0].MeterailID);
                        if (injectionMaterial != null)
                        {
                            lblmeterial.Text = injectionMaterial.Name;
                        }
                        else
                        {
                            lblmeterial.Text = "";
                        }

                    }

                }
                else {
                    lblmachine.Text = "";
                    lblsharp.Text = "";
                }

            }
        }