Ejemplo n.º 1
0
        public int CreateFinishingNumber(FinishingNumbers newFinishingNumbers)
        {
            int result = -1;
            try
            {
                conn = db.openConn();
                tr = conn.BeginTransaction();
                sb = new StringBuilder();
                sb.Remove(0, sb.Length);
                sb.Append("INSERT INTO finishing_numbers(complete_no,rev,place_name,user_create_name,create_date,status)");
                sb.Append(" VALUES (@complete_no,@rev,@place_name,@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("@complete_no", SqlDbType.NVarChar).Value = newFinishingNumbers.CompleteNo;
                comm.Parameters.Add("@rev", SqlDbType.NVarChar).Value = newFinishingNumbers.Rev;
                comm.Parameters.Add("@place_name", SqlDbType.NVarChar).Value = newFinishingNumbers.PlaceName;
                comm.Parameters.Add("@user_create_name", SqlDbType.NVarChar).Value = newFinishingNumbers.UserCreateName;
                comm.Parameters.Add("@create_date", SqlDbType.NVarChar).Value = newFinishingNumbers.CreateDate;
                comm.Parameters.Add("@status", SqlDbType.NVarChar).Value = newFinishingNumbers.Status;
                comm.ExecuteNonQuery();
                tr.Commit();

                result = 1;

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

            }
            finally
            {
                conn.Close();
            }
            return result;
        }
Ejemplo n.º 2
0
        public int UpdateFinishingNumber(FinishingNumbers _finishingNumbers)
        {
            int result = -1;
            try
            {
                conn = db.openConn();
                tr = conn.BeginTransaction();

                sb = new StringBuilder();

                sb.Remove(0, sb.Length);
                sb.Append(" UPDATE finishing_numbers ");
                sb.Append(" SET rev='" + _finishingNumbers.Rev + "',");
                sb.Append(" place_name='" + _finishingNumbers.PlaceName + "'");
                sb.Append(" WHERE (complete_no='" + _finishingNumbers.CompleteNo+ "')");
                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;
        }
Ejemplo n.º 3
0
        public List<FinishingNumbers> getFinishingNumbersAll()
        {
            List<FinishingNumbers> finishingNumbers = new List<FinishingNumbers>();
            FinishingNumbers fbl = null;
            try
            {
                conn = db.openConn();
                sb = new StringBuilder();
                sb.Remove(0, sb.Length);
                sb.Append(" select  complete_no,rev,place_name,user_create_name,create_date,status from  dbo.finishing_numbers");
                //sb.Append(" where  complete_no  ='" + _completeno + "'");
                //sb.Append(" and  product_text_date  ='" + _product_text_date + "'");

                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)
                    {
                        fbl = new FinishingNumbers();
                        fbl.CompleteNo = drw["complete_no"].ToString();
                        fbl.Rev = drw["rev"].ToString();
                        fbl.PlaceName = drw["place_name"].ToString();
                        fbl.UserCreateName = drw["user_create_name"].ToString();
                        fbl.CreateDate = Convert.ToDateTime(drw["create_date"].ToString());
                        fbl.Status = drw["status"].ToString();
                        finishingNumbers.Add(fbl);
                    }
                }

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

            }
            finally
            {
                conn.Close();
            }

            return finishingNumbers;
        }