Beispiel #1
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Create new Customer and return Customer id auto increment
        /// </summary>
        /// <param name="pCustomer">Customer</param>
        public int Create(Customer pCustomer)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@Code", DbType.String, 10),
                MakeParameter("@Name", DbType.String, 200),
                MakeParameter("@ADDRESS", DbType.String, 400),
                MakeParameter("@TEL", DbType.String, 20),
                MakeParameter("@FAX", DbType.String, 20),
                MakeParameter("@WEB", DbType.String, 400),
                MakeParameter("@EMAIL", DbType.String, 400),
                MakeParameter("@CONTACT_NAME", DbType.String, 200),
                MakeParameter("@CONTACT_TEL", DbType.String, 20),
                MakeParameter("@CONTACT_EMAIL", DbType.String, 400)
            };

            parameters[0].Value = pCustomer.Code;
            parameters[1].Value = pCustomer.Name;
            parameters[2].Value = pCustomer.Adress;
            parameters[3].Value = pCustomer.Tel;
            parameters[4].Value = pCustomer.Fax;
            parameters[5].Value = pCustomer.Web;
            parameters[6].Value = pCustomer.Email;
            parameters[7].Value = pCustomer.ContactName;
            parameters[8].Value = pCustomer.ContactTel;
            parameters[9].Value = pCustomer.ContactEmail;
            int rowAffected = 0;
            return RunProcedure("sp_ADV_Customer_INSERT", parameters, out rowAffected);
        }
Beispiel #2
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Process add Customer in UI
        /// </summary>
        /// <param name="pCustomer">Customer</param>
        public void AddCustomerUI(Customer pCustomer)
        {
            // Add row to grid
            DataRow row = ((DataView)mdgrCustomer.DataSource).Table.NewRow();
            row["Customer_ID"] = pCustomer.CustomerID;
            row["CODE"] = pCustomer.Code;
            row["NAME"] = pCustomer.Name;
            row["ADDRESS"] = pCustomer.Adress;
            row["TEL"] = pCustomer.Tel;
            row["FAX"] = pCustomer.Fax;
            row["WEB"] = pCustomer.Web;
            row["EMAIL"] = pCustomer.Email;
            row["CONTACT_NAME"] = pCustomer.ContactName;
            row["CONTACT_TEL"] = pCustomer.ContactTel;
            row["CONTACT_EMAIL"] = pCustomer.ContactEmail;
            row["##STT##"] = mdgrCustomer.Rows.Count + 1;
            ((DataView)mdgrCustomer.DataSource).Table.Rows.Add(row);

            // change current row to last row
            mdgrCustomer.CurrentCell = mdgrCustomer.Rows[mdgrCustomer.RowCount - 1].Cells[0];
            mdgrCustomer.CurrentRow.Selected = true;
            SetButtonStatus();
            // Change current row to the new row
            //mdgrCustomer.CurrentRow.Selected = false;
            //mintCurrentRow = mdgrCustomer.RowCount - 1;
            //mdgrCustomer.Rows[mdgrCustomer.RowCount - 1].Selected = true;
            //GenSTT();
        }
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Constrctor to update selected Customer
 /// </summary>
 public FrmCustomerItem(FrmCustomer frmCustomer, Customer pCustomer)
     : this()
 {
     mfrmCustomer = frmCustomer;
     mCustomer = pCustomer;
     //mOldCustomer = System.Clo
     mblnUpdate = true;
     this.Text = "Cap nhat khach hang";
 }
Beispiel #4
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Delete 1 Customer with Customer_id
        /// </summary>
        /// <param name="pCustomer">Customer</param>
        public int Delete(Customer pCustomer)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@Customer_ID", DbType.Int32, 10)
            };

            parameters[0].Value = pCustomer.CustomerID;
            int rowAffected = 0;
            RunProcedure("sp_ADV_Customer_DELETE", parameters, out rowAffected);
            return rowAffected;
        }
Beispiel #5
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Insert 1 Customer and return Customer_id auto increment
 /// </summary>
 public int Add(Customer pCustomer)
 {
     PrCustomer Customer = new PrCustomer(Connection);
     int intCustomerID = -1;
     try
     {
         Open();
         intCustomerID = Customer.Create(pCustomer);
         Commit();
     }
     catch (Exception exp)
     {
         Rollback();
         throw exp;
     }
     finally
     {
         Close();
     }
     return intCustomerID;
 }
Beispiel #6
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Delete 1 Customer with Customer_id
 /// </summary>
 public int Delete(Customer pCustomer)
 {
     PrCustomer Customer = new PrCustomer(Connection);
     int intRowAffected = 0;
     try
     {
         Open();
         intRowAffected = Customer.Delete(pCustomer);
         Commit();
     }
     catch (Exception exp)
     {
         Rollback();
         throw exp;
     }
     finally
     {
         Close();
     }
     return intRowAffected;
 }
Beispiel #7
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Retrieves all Customer
 /// </summary>
 public DataSet Retrieves(Customer pCustomer)
 {
     PrCustomer Customer = new PrCustomer(Connection);
     try
     {
         Open();
         return Customer.Search(pCustomer);
     }
     catch (Exception exp)
     {
         throw exp;
     }
     finally
     {
         Close();
     }
 }
Beispiel #8
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/03/2008
        /// @Description: Searh Customer by many param
        /// </summary>
        public DataSet Search(Customer pCustomer)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@CUSTOMER_ID", DbType.Int32, 4),
                MakeParameter("@CODE", DbType.String, 10),
                MakeParameter("@NAME", DbType.String, 200)
            };

            parameters[0].Value = (pCustomer.CustomerID < 0) ? (object)DBNull.Value : (object)pCustomer.CustomerID;
            parameters[1].Value = (pCustomer.Code == null) ? (object)DBNull.Value : (object)pCustomer.Code;
            parameters[2].Value = (pCustomer.Name == null) ? (object)DBNull.Value : (object)pCustomer.Name;
            return RunProcedure("sp_ADV_Customer_SELECT_SEARCH", parameters, "ADV_Customer");
        }
Beispiel #9
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: make search param depend on combo box
 /// </summary>
 private Customer MakeSearchParam()
 {
     Customer customer = new Customer();
     customer.CustomerID = -1;
     customer.Code = (mcboSearch.SelectedIndex == 1) ? mtxtSearch.Text.Trim() : null;
     customer.Name = (mcboSearch.SelectedIndex == 2) ? mtxtSearch.Text.Trim() : null;
     return customer;
 }
Beispiel #10
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Update new Customer in UI
 /// </summary>
 /// <param name="pCustomer">Customer</param>
 public void UpdateCustomerUI(Customer pCustomer)
 {
     // Update from data to row in grid
     mdgrCustomer.CurrentRow.Cells["NAME"].Value = pCustomer.Name;
     mdgrCustomer.CurrentRow.Cells["CODE"].Value = pCustomer.Code;
     mdgrCustomer.CurrentRow.Cells["ADDRESS"].Value = pCustomer.Adress;
     mdgrCustomer.CurrentRow.Cells["TEL"].Value = pCustomer.Tel;
     mdgrCustomer.CurrentRow.Cells["FAX"].Value = pCustomer.Fax;
     mdgrCustomer.CurrentRow.Cells["WEB"].Value = pCustomer.Web;
     mdgrCustomer.CurrentRow.Cells["EMAIL"].Value = pCustomer.Email;
     mdgrCustomer.CurrentRow.Cells["CONTACT_NAME"].Value = pCustomer.ContactName;
     mdgrCustomer.CurrentRow.Cells["CONTACT_TEL"].Value = pCustomer.ContactTel;
     mdgrCustomer.CurrentRow.Cells["CONTACT_EMAIL"].Value = pCustomer.ContactEmail;
 }
Beispiel #11
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/03/2008
 /// @Description: Get current Customer from grid
 /// </summary>
 /// <param name="return">Customer</param>
 public Customer GetCurrentCustomer()
 {
     // Get current row data into Customer
     Customer Customer = new Customer();
     Customer.CustomerID = ((Int32)mdgrCustomer.CurrentRow.Cells["Customer_ID"].Value);
     Customer.Code = (String)mdgrCustomer.CurrentRow.Cells["CODE"].Value;
     Customer.Name = (String)mdgrCustomer.CurrentRow.Cells["NAME"].Value;
     Customer.Adress = (String)mdgrCustomer.CurrentRow.Cells["ADDRESS"].Value;
     Customer.Tel = (String)mdgrCustomer.CurrentRow.Cells["TEL"].Value;
     Customer.Fax = (String)mdgrCustomer.CurrentRow.Cells["FAX"].Value;
     Customer.Web = (String)mdgrCustomer.CurrentRow.Cells["WEB"].Value;
     Customer.Email = (String)mdgrCustomer.CurrentRow.Cells["EMAIL"].Value;
     Customer.ContactName = (String)mdgrCustomer.CurrentRow.Cells["CONTACT_NAME"].Value;
     Customer.ContactTel = (String)mdgrCustomer.CurrentRow.Cells["CONTACT_TEL"].Value;
     Customer.ContactEmail = (String)mdgrCustomer.CurrentRow.Cells["CONTACT_EMAIL"].Value;
     //Customer.CustomerID = ((Int32)mdgrCustomer["Customer_ID", mintCurrentRow].Value);
     //Customer.Code = (String)mdgrCustomer["CODE", mintCurrentRow].Value;
     //Customer.Name = (String)mdgrCustomer["NAME", mintCurrentRow].Value;
     //Customer.Adress = (String)mdgrCustomer["ADDRESS", mintCurrentRow].Value;
     //Customer.Tel = (String)mdgrCustomer["TEL", mintCurrentRow].Value;
     //Customer.Fax = (String)mdgrCustomer["FAX", mintCurrentRow].Value;
     //Customer.Web = (String)mdgrCustomer["WEB", mintCurrentRow].Value;
     //Customer.Email = (String)mdgrCustomer["EMAIL", mintCurrentRow].Value;
     //Customer.ContactName = (String)mdgrCustomer["CONTACT_NAME", mintCurrentRow].Value;
     //Customer.ContactTel = (String)mdgrCustomer["CONTACT_TEL", mintCurrentRow].Value;
     //Customer.ContactEmail = (String)mdgrCustomer["CONTACT_EMAIL", mintCurrentRow].Value;
     // Return
     return Customer;
 }