private void btnSave2_Click(object sender, RoutedEventArgs e)
        {
            // Update ForecastOrder set SalesId and CustomerId
            string customerId   = "";
            string customerName = "";

            string[]    sales   = null;
            string      salesId = "";
            CustomerBEL objBEL  = new CustomerBEL();

            for (int i = 0; i < dgCustomerData2.Items.Count; i++)
            {
                DataGridCell cell0 = FunctionClass.GetCell(dgCustomerData2, i, 0);
                DataGridCell cell1 = FunctionClass.GetCell(dgCustomerData2, i, 1);
                DataGridCell cell2 = FunctionClass.GetCell(dgCustomerData2, i, 2);
                TextBlock    tb0   = cell0.Content as TextBlock;
                TextBlock    tb1   = cell1.Content as TextBlock;
                ComboBox     cb    = cell2.Content as ComboBox;
                customerId   = tb0.Text.Trim();
                customerName = tb1.Text.Trim();
                if (cb.SelectedValue != null)
                {
                    sales   = cb.SelectedValue.ToString().Split('-');
                    salesId = sales[0].ToString().Trim();
                    ForecastOrderBLL.updateForecastOrder(salesId, customerId, customerName);
                    objBEL.Id        = customerId;
                    objBEL.Name      = customerName;
                    objBEL.CountryId = "";
                    objBEL.IsEnable  = "1";
                    objBEL.SalesId   = salesId;
                    CustomerBLL.insertCustomer(objBEL);
                }
            }
        }
Exemplo n.º 2
0
        public static Int32 insertCustomer(CustomerBEL objBel)
        {
            CustomerDAL objDal = new CustomerDAL();

            try
            {
                return(objDal.insertCustomer(objBel));
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                objDal = null;
            }
        }
Exemplo n.º 3
0
        public Int32 insertCustomer(CustomerBEL objBEL)
        {
            int result;

            try
            {
                SqlCommand cmd = new SqlCommand("dbo.sp_insertCustomer", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Id", objBEL.Id);
                cmd.Parameters.AddWithValue("@Name", objBEL.Name);
                cmd.Parameters.AddWithValue("@SalesId", objBEL.SalesId);
                cmd.Parameters.AddWithValue("@CountryId", objBEL.CountryId);
                cmd.Parameters.AddWithValue("@IsEnable", objBEL.IsEnable);

                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                result = cmd.ExecuteNonQuery();
                cmd.Dispose();
                if (result > 0)
                {
                    return(result);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }
            }
        }