示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtCustomerName.Text))
            {
                MessageBox.Show("Customer name is empty");
            }
            else
            {
                if (!isUpdate)
                {
                    var customer = new CustomerDetailDTO();
                    customer.CsutomerName = txtCustomerName.Text.Trim();

                    if (bll.Insert(customer))
                    {
                        MessageBox.Show("Customer was added");
                        txtCustomerName.Clear();
                    }
                }
                else if (isUpdate)
                {
                    detail.CsutomerName = txtCustomerName.Text.Trim();
                    if (bll.Update(detail))
                    {
                        MessageBox.Show("Updated");
                        this.Close();
                    }
                }
            }
        }
        public int AddCustomerDetailData(CustomerDetailDTO customerDeatil)
        {
            CustomerDetail.Customer customer
                = new CustomerDetail.Customer(customerDeatil.UserId, customerDeatil.ChtName, customerDeatil.Location);

            // 檢查(帳號/身分證號)是否為特殊身分
            _customerService.CheckIsSpecialAccount(customer, customerDeatil.UserId);

            // Process and others..
            return(_customerDetailRepository.Save(customer));
        }
示例#3
0
 private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (cmbDeletedData.SelectedIndex == 0)
     {
         categorydetail              = new CategoryDetailDTO();
         categorydetail.ID           = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
         categorydetail.CategoryName = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
     }
     else if (cmbDeletedData.SelectedIndex == 1)
     {
         customerdetail              = new CustomerDetailDTO();
         customerdetail.ID           = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
         customerdetail.CustomerName = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
     }
     else if (cmbDeletedData.SelectedIndex == 2)
     {
         productdetail                   = new ProductDetailDTO();
         productdetail.ProductID         = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[4].Value);
         productdetail.CategoryID        = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[5].Value);
         productdetail.ProductName       = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
         productdetail.Price             = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[3].Value);
         productdetail.isCategoryDeleted = Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[6].Value);
     }
     else
     {
         salesdetail                   = new SalesDetailDTO();
         salesdetail.SalesID           = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[10].Value);
         salesdetail.ProductID         = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[4].Value);
         salesdetail.CustomerName      = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
         salesdetail.ProductName       = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
         salesdetail.Price             = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[7].Value);
         salesdetail.SalesAmount       = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[6].Value);
         salesdetail.isCategoryDeleted = Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[11].Value);
         salesdetail.isCustomerDeleted = Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[12].Value);
         salesdetail.isProductDeleted  = Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[13].Value);
     }
 }
示例#4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtCustomerName.Text.Trim() == "")
     {
         MessageBox.Show("Customer name is empty");
     }
     else
     {
         if (!isUpdate)
         {
             CustomerDetailDTO customer = new CustomerDetailDTO();
             customer.CustomerName = txtCustomerName.Text;
             if (bll.Insert(customer))
             {
                 MessageBox.Show("Customer was added");
                 txtCustomerName.Clear();
             }
         }
         else
         {
             if (detail.CustomerName == txtCustomerName.Text)
             {
                 MessageBox.Show("There is no change");
             }
             else
             {
                 detail.CustomerName = txtCustomerName.Text;
                 if (bll.Update(detail))
                 {
                     MessageBox.Show("Customer was updated");
                 }
                 this.Close();
             }
         }
     }
 }
示例#5
0
 public int AddBasicCustomerDetailData(CustomerDetailDTO customerDetail)
 {
     return(_customerBasicDetailRegisterHandler.AddCustomerDetailData(customerDetail));
 }
示例#6
0
 private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     detail              = new CustomerDetailDTO();
     detail.ID           = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
     detail.CustomerName = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
 }
示例#7
0
        public bool MoveCustomer(CustomertoMove objCustomer)
        {
            bool res = false;
            CustomerDetailDTO cus    = new CustomerDetailDTO();
            SqlCommand        SqlCmd = new SqlCommand("MoveToCustomer");

            SqlCmd.CommandType = CommandType.StoredProcedure;
            SqlCmd.Parameters.AddWithValue("@ClientId", (objCustomer.ClientId == 0) ? null : objCustomer.ClientId);
            SqlCmd.Parameters.AddWithValue("@CustomerId", (objCustomer.CustomerId == 0) ? null : objCustomer.CustomerId);
            SqlCmd.Parameters.AddWithValue("@DateofCommencement", objCustomer.DateOfCommencement);
            SqlCmd.Parameters.AddWithValue("@AgreementSigned", objCustomer.AgreementSigned);
            SqlCmd.Parameters.AddWithValue("@TypeofContract", objCustomer.TypeofContract);
            SqlCmd.Parameters.AddWithValue("@FromDate", objCustomer.FromDate);
            SqlCmd.Parameters.AddWithValue("@ToDate", objCustomer.ToDate);
            SqlCmd.Parameters.AddWithValue("@ClientType", objCustomer.ClientType);
            SqlCmd.Parameters.AddWithValue("@ActionBy", objCustomer.CreatedBy);
            cus = _unitOfWork.DbLayer.GetEntityList <CustomerDetailDTO>(SqlCmd).FirstOrDefault();
            if (cus != null)
            {
                SqlCommand sqlCmd1 = new SqlCommand("spInsertCustomerManagementDetail");
                sqlCmd1.CommandType = CommandType.StoredProcedure;
                sqlCmd1.Parameters.AddWithValue("@CustomerId", cus.Customer);
                sqlCmd1.Parameters.AddWithValue("@CreatedBy", objCustomer.CreatedBy);
                sqlCmd1.Parameters.Add(new SqlParameter("@Department", SqlDbType.VarChar));
                sqlCmd1.Parameters.Add(new SqlParameter("@ContactPersonName", SqlDbType.VarChar));
                sqlCmd1.Parameters.Add(new SqlParameter("@ContactNumber", SqlDbType.VarChar));
                sqlCmd1.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar));
                sqlCmd1.Parameters.Add(new SqlParameter("@Address", SqlDbType.VarChar));
                foreach (var detail in objCustomer.ClientDetail)
                {
                    if (sqlCmd1.Connection != null)
                    {
                        if (sqlCmd1.Connection.State == ConnectionState.Closed)
                        {
                            sqlCmd1.Connection.Open();
                        }
                    }

                    sqlCmd1.Parameters["@Department"].Value        = (detail.Department == null) ? null : detail.Department;
                    sqlCmd1.Parameters["@ContactPersonName"].Value = (detail.ContactPersonName == null) ? null : detail.ContactPersonName;
                    sqlCmd1.Parameters["@ContactNumber"].Value     = (detail.ContactNumber == null) ? null : detail.ContactNumber;
                    sqlCmd1.Parameters["@Email"].Value             = (detail.Email == null) ? null : detail.Email;
                    sqlCmd1.Parameters["@Address"].Value           = (detail.Address == null) ? null : detail.Address;
                    int queryRes = _unitOfWork.DbLayer.ExecuteNonQuery(sqlCmd1);
                    if (queryRes != Int32.MaxValue)
                    {
                        res = true;
                    }
                    else
                    {
                        // this part needed error handling code.
                        res = false;
                    }
                }
            }

            if (cus.ContractId != null || cus.ContractId != 0)
            {
                SqlCommand sqlCmd1 = new SqlCommand("spInsertShiftMapping");
                sqlCmd1.CommandType = CommandType.StoredProcedure;
                sqlCmd1.Parameters.AddWithValue("@ContractId", cus.ContractId);
                sqlCmd1.Parameters.AddWithValue("@CreatedBy", objCustomer.CreatedBy);
                sqlCmd1.Parameters.Add(new SqlParameter("@ShiftId", SqlDbType.VarChar));
                sqlCmd1.Parameters.Add(new SqlParameter("@StartTime", SqlDbType.VarChar));
                sqlCmd1.Parameters.Add(new SqlParameter("@EndTime", SqlDbType.VarChar));
                foreach (var shift in objCustomer.ShiftMapping)
                {
                    if (sqlCmd1.Connection != null)
                    {
                        if (sqlCmd1.Connection.State == ConnectionState.Closed)
                        {
                            sqlCmd1.Connection.Open();
                        }
                    }

                    sqlCmd1.Parameters["@ShiftId"].Value   = shift.ShiftId;
                    sqlCmd1.Parameters["@StartTime"].Value = shift.StartTime;
                    sqlCmd1.Parameters["@EndTime"].Value   = shift.EndTime;
                    int queryRes = _unitOfWork.DbLayer.ExecuteNonQuery(sqlCmd1);
                    if (queryRes != Int32.MaxValue)
                    {
                        res = true;
                    }
                    else
                    {
                        // this part needed error handling code.
                        res = false;
                    }
                }
            }


            return(res);
        }