public List<InjectionCabinetNumber> getInjectionAllTotal()
        {
            List<InjectionCabinetNumber> injectionCabinetNumbers = new List<InjectionCabinetNumber>();
            InjectionCabinetNumber inc;
            try
            {
                conn = db.openConn();
                sb = new StringBuilder();
                sb.Remove(0, sb.Length);
                sb.Append(" SELECT id,part,complete_no,rev,material_no,color_no,machine_no,user_create_name,create_date,status FROM injection_cabinet_numbers ");
                // sb.Append(" WHERE complete_no='" + _completeNo + "'");

                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)
                    {
                        inc = new InjectionCabinetNumber();
                        inc.ID = Convert.ToInt32(drw["id"].ToString());
                        inc.Part = drw["part"].ToString();
                        inc.CompleteNo = drw["complete_no"].ToString();
                        inc.Rev = drw["rev"].ToString();

                        InjectionMaterial injectionMaterial = meterialService.getByID(Convert.ToString(drw["material_no"].ToString()));
                        inc.MeterailID = Convert.ToString(injectionMaterial.ID);
                        inc.MeterialName = injectionMaterial.Name;

                        InjectionColor injectionColor = colorService.getByID(Convert.ToString(drw["color_no"].ToString()));
                        inc.ColorID = Convert.ToString(injectionColor.ID);
                        inc.ColorName = injectionColor.Name;

                        InjectionMachine injectionMachine = machineService.getByID(Convert.ToString(drw["machine_no"].ToString()));
                        inc.MechineID = Convert.ToString(injectionMachine.ID);
                        inc.MechineName = injectionMachine.Name;
                        inc.MoldNo = injectionMachine.MoldNo;

                        inc.UserCreateName = drw["user_create_name"].ToString();
                        inc.CreateDate = Convert.ToDateTime(drw["create_date"].ToString());
                        inc.Status = drw["status"].ToString();
                        injectionCabinetNumbers.Add(inc);

                    }
                }

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

            }
            finally
            {
                conn.Close();
            }
            return injectionCabinetNumbers;
        }
        public int UpdateInjectionCabinetNumber(InjectionCabinetNumber _injectionCabinetNumber)
        {
            int result = -1;
            try
            {
                conn = db.openConn();
                tr = conn.BeginTransaction();

                sb = new StringBuilder();

                sb.Remove(0, sb.Length);
                sb.Append(" UPDATE injection_cabinet_numbers ");
                sb.Append(" SET rev='" + _injectionCabinetNumber.Rev + "',");
                sb.Append(" material_no='" + _injectionCabinetNumber.MechineID + "',");
                sb.Append(" color_no='" + _injectionCabinetNumber.ColorID + "',");
                sb.Append(" machine_no='" + _injectionCabinetNumber.MechineID + "'");
                sb.Append(" WHERE (complete_no='" + _injectionCabinetNumber.CompleteNo + "')");
                sb.Append(" and (part='" + _injectionCabinetNumber.Part + "')");
                string sqlUpdate;
                sqlUpdate = sb.ToString();

                comm = new SqlCommand();
                comm.Connection = conn;
                comm.CommandText = sqlUpdate;
                comm.Transaction = tr;
                comm.Parameters.Clear();
                comm.ExecuteNonQuery();
                tr.Commit();

                result = 1;

            }
            catch (Exception ex)
            {
                tr.Rollback();
                conn.Close();
                return result;
                throw ex;

            }
            finally
            {
                conn.Close();
            }

            return result;
        }
        public int CreateInjectionCabinetNumber(InjectionCabinetNumber newInjectionCabinetNumber)
        {
            int result = -1;
            try
            {
                conn = db.openConn();
                tr = conn.BeginTransaction();
                sb = new StringBuilder();
                sb.Remove(0, sb.Length);
                sb.Append("INSERT INTO injection_cabinet_numbers(part,complete_no,rev,material_no,color_no,machine_no,user_create_name,create_date,status)");
                sb.Append(" VALUES (@part,@complete_no,@rev,@material_no,@color_no,@machine_no,@user_create_name,@create_date,@status)");

                string sqlsave;
                sqlsave = sb.ToString();

                comm = new SqlCommand();
                comm.Connection = conn;
                comm.Transaction = tr;
                comm.CommandText = sqlsave;
                comm.Parameters.Clear();
                comm.Parameters.Add("@part", SqlDbType.NVarChar).Value = newInjectionCabinetNumber.Part;
                comm.Parameters.Add("@complete_no", SqlDbType.NVarChar).Value = newInjectionCabinetNumber.CompleteNo;
                comm.Parameters.Add("@rev", SqlDbType.NVarChar).Value = newInjectionCabinetNumber.Rev;
                comm.Parameters.Add("@material_no", SqlDbType.NVarChar).Value = newInjectionCabinetNumber.MeterailID;
                comm.Parameters.Add("@color_no", SqlDbType.NVarChar).Value = newInjectionCabinetNumber.ColorID;
                comm.Parameters.Add("@machine_no", SqlDbType.NVarChar).Value = newInjectionCabinetNumber.MechineID;
                comm.Parameters.Add("@user_create_name", SqlDbType.NVarChar).Value = newInjectionCabinetNumber.UserCreateName;
                comm.Parameters.Add("@create_date", SqlDbType.DateTime).Value = newInjectionCabinetNumber.CreateDate;
                comm.Parameters.Add("@status", SqlDbType.NVarChar).Value = newInjectionCabinetNumber.Status;
                comm.ExecuteNonQuery();
                tr.Commit();

                result = 1;

            }
            catch (Exception ex)
            {
                tr.Rollback();
                conn.Close();
                return result;
                throw ex;

            }
            finally
            {
                conn.Close();
            }
            return result;
        }