public int UpdatePrintNumber(PrintingNumber _printingNumber)
        {
            int result = -1;
            try
            {
                conn = db.openConn();
                tr = conn.BeginTransaction();

                sb = new StringBuilder();

                sb.Remove(0, sb.Length);
                sb.Append(" UPDATE printing_numbers ");
                sb.Append(" SET rev='" + _printingNumber.Rev + "',");
                sb.Append(" color_no='" + _printingNumber.ColorNo + "',");
                sb.Append(" process='" + _printingNumber.Process + "'");
                sb.Append(" WHERE (complete_no='" + _printingNumber.CompleteNo + "')");
                sb.Append(" and (part='" + _printingNumber.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 CreatePrintingNumber(PrintingNumber newPrintingNumber)
        {
            int result = -1;
            try
            {
                conn = db.openConn();
                tr = conn.BeginTransaction();
                sb = new StringBuilder();
                sb.Remove(0, sb.Length);
                sb.Append("INSERT INTO printing_numbers(part,complete_no,rev,color_no,process,user_create_name,create_date,status)");
                sb.Append(" VALUES (@part,@complete_no,@rev,@color_no,@process,@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 = newPrintingNumber.Part;
                comm.Parameters.Add("@complete_no", SqlDbType.NVarChar).Value = newPrintingNumber.CompleteNo;
                comm.Parameters.Add("@rev", SqlDbType.NVarChar).Value = newPrintingNumber.Rev;
                comm.Parameters.Add("@color_no", SqlDbType.NVarChar).Value = newPrintingNumber.ColorNo;
                comm.Parameters.Add("@process", SqlDbType.NVarChar).Value = newPrintingNumber.Process;
                comm.Parameters.Add("@user_create_name", SqlDbType.NVarChar).Value = newPrintingNumber.UserCreateName;
                comm.Parameters.Add("@create_date", SqlDbType.DateTime).Value = newPrintingNumber.CreateDate;
                comm.Parameters.Add("@status", SqlDbType.NVarChar).Value = newPrintingNumber.Status;
                comm.ExecuteNonQuery();
                tr.Commit();

                result = 1;

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

            }
            finally
            {
                conn.Close();
            }
            return result;
        }
        public List<PrintingNumber> getPrintingNumberAllByPart(string _part,string _completeno)
        {
            List<PrintingNumber> printingNumbers = new List<PrintingNumber>();
            PrintingNumber inc;
            try
            {
                conn = db.openConn();
                sb = new StringBuilder();
                sb.Remove(0, sb.Length);
                sb.Append(" SELECT part,complete_no,rev,color_no,process,user_create_name,create_date,status FROM printing_numbers ");
                sb.Append(" WHERE part='" + _part + "'");
                sb.Append(" and 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 PrintingNumber();
                        inc.ID = 0;
                        inc.Part = drw["part"].ToString();
                        inc.CompleteNo = drw["complete_no"].ToString();
                        inc.Rev = drw["rev"].ToString();
                        inc.ColorNo = drw["color_no"].ToString();
                        inc.Process = drw["process"].ToString();
                        inc.UserCreateName = drw["user_create_name"].ToString();
                        inc.CreateDate = Convert.ToDateTime(drw["create_date"].ToString());
                        inc.Status = drw["status"].ToString();
                        printingNumbers.Add(inc);

                    }
                }

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

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