public void CRUDTest()
        {
            string contactName = "someContact" + DateTime.Now.Second;
            Customer c = new Customer(contactName);
            CustomerDAO cdao = new CustomerDAO();
            cdao.Save(c);
            
            RestartBurrowEnvironment();

            c = cdao.Get(c.Id);
            Assert.AreEqual(contactName, c.ContactName);

            cdao.Delete(c);
        }
Beispiel #2
0
        private void txtPhone_TextChanged(object sender, EventArgs e)
        {
            string      phone  = txtPhone.Text;
            CustomerDAO dao    = new CustomerDAO();
            string      result = dao.checkCustomer(phone);

            if (result != null)
            {
                lblfullNameH.Text = result;
                OrderDAO  oDao = new OrderDAO();
                DataTable oder = oDao.getListOrder(phone);
                if (oder.Rows.Count == 0)
                {
                    MessageBox.Show("Khách hàng đã trả hết sách");
                }
                dgvHistory.DataSource = oder;
                dgvHistory.ClearSelection();
            }
            else
            {
                lblfullNameH.Text = "Khách hàng không tồn tại";
            }
        }
 public ActionResult EditCustomer(CustomerModel model)
 {
     if (ModelState.IsValid)
     {
         var customerDao = new CustomerDAO();
         if (customerDao.CheckEmail(model.Email) && !customerDao.CheckEmailCustomer(model))
         {
             ModelState.AddModelError("", "This email has already existed.");
         }
         else if (customerDao.CheckPhoneNumber(model.PhoneNumber) && !customerDao.CheckPhoneNumberCustomer(model))
         {
             ModelState.AddModelError("", "This phone number has already existed.");
         }
         else
         {
             var adminDao = new AdminDAO();
             adminDao.updateCustomer(model);
             string message = "Update customer successfully.";
             return(RedirectToAction("AdminHome", "Admin", new { message }));
         }
     }
     return(View(model));
 }
Beispiel #4
0
        /// <summary>
        /// 读取指定客户记录
        /// </summary>
        /// <param name="nCustomerId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public Customer LoadCustomer(long nCustomerId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                Customer dataResult = null;
                strErrText = String.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (CustomerDAO dao = new CustomerDAO())
                    {
                        dataResult = dao.LoadCustomer(nCustomerId, nOpStaffId, strOpStaffName, out strErrText);
                    }
                    transScope.Complete();
                }
                return(dataResult);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(null);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 读取指定时间段内发生仓储力支费的客户数据
        /// </summary>
        /// <param name="strStartTime"></param>
        /// <param name="strEndTime"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public List <Customer> LoadGenerateStorageAndForceFeeCustomersByTimespan(string strStartTime, string strEndTime, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                List <Customer> dataResult = null;
                strErrText = String.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (CustomerDAO dao = new CustomerDAO())
                    {
                        dataResult = dao.LoadGenerateStorageAndForceFeeCustomersByTimespan(strStartTime, strEndTime, nOpStaffId, strOpStaffName, out strErrText);
                    }
                    transScope.Complete();
                }
                return(dataResult);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(null);
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (!CheckData())
            {
                return;
            }

            CustomerBean c = new CustomerBean();

            c.Name    = customer;
            c.Phone   = phone;
            c.Sex     = sex;
            c.IdCard  = idCard;
            c.Email   = email;
            c.Address = address;
            c.Remark  = remark;
            c.Age     = age;

            MD5 md5 = MD5.Create();

            byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(passwd));
            c.Password = Convert.ToBase64String(s);

            c.Baby     = student;
            c.BabyAge  = age;
            c.Relation = relation;

            CustomerDAO dao = new CustomerDAO();

            if (dao.FindCustomer(c) == false)
            {
                if (dao.AddCustomer(c) == 1)
                {
                    MessageBox.Show("注册成功", "信息提示", MessageBoxButtons.OK);
                }
            }
        }
        public ActionResult UpdateCustomer()
        {
            CustomerDTO cus      = (CustomerDTO)Session["CUSTOMER"];
            string      username = cus.Username;
            string      fullname = Request["txtFullname"];
            string      tel      = Request["txtPhone"];
            string      address  = Request["txtAddress"];
            string      email    = Request["txtEmail"];
            CustomerDAO dao      = new CustomerDAO();
            CustomerDTO tmp      = new CustomerDTO(username, fullname, email, address, tel);
            bool        result   = dao.UpdateCustomer(tmp);

            if (result)
            {
                cus.CustomerName          = fullname;
                cus.Email                 = email;
                cus.Address               = address;
                cus.Phone                 = tel;
                TempData["UpdateSuccess"] = "Update infomation successful.";
                return(RedirectToAction("ShowCusInfo"));
            }

            return(View());
        }
        public ActionResult ShowCusInfo()
        {
            if (Session["LISTBILL"] != null) // refresh List bill if customer buy some thing
            {
                Session.Remove("LISTBILL");
            }

            BillDAO        dao      = new BillDAO();
            CustomerDTO    cus      = (CustomerDTO)Session["CUSTOMER"];
            string         cusId    = cus.Username;
            List <BillDTO> listBill = dao.GetAllBillOfCus(cusId);
            CustomerDAO    daoCus   = new CustomerDAO();
            string         rank     = daoCus.GetRank(cusId);

            if (!rank.Equals(""))
            {
                cus.Rank = rank;
            }

            Session["LISTBILL"] = listBill;


            return(View("ViewCusInfo"));
        }
Beispiel #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (btn.Text == "Add")
            {
                displayButtons(2);
            }
            else
            {
                char gender = new char();
                if (gendertxt.Text != "")
                {
                    gender = gendertxt.Text[0];
                }
                b = new Customer(CustomerDAO.GetIdMax() + 1, nametxt.Text, gender, addresstxt.Text, telephonetxt.Text, emailtxt.Text);

                CustomerDAO.Insert(b);

                view();

                displayButtons(1);
            }
        }
 private void LoadInitialData()
 {
     try
     {
         //
         // Fill Customer Code
         //
         DataSet dsCustomers = new CustomerDAO().GetAllCustomers();
         if (dsCustomers == null || dsCustomers.Tables.Count == 0)
         {
             ddlCustomerCode.Items.Add(new ListItem("--No Data Found--", "-1"));
         }
         else
         {
             Master.BindDropdown("Cus_Name", "CustomerID", dsCustomers, ddlCustomerCode);
             ddlCustomerCode.Items.Add(new ListItem("--Please Select--", "-1"));
             ddlCustomerCode.SelectedValue = "-1";
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #11
0
 public ActionResult Edit(CustomerUser acc)
 {
     if (ModelState.IsValid)
     {
         var dao = new CustomerDAO();
         if (!string.IsNullOrEmpty(acc.MatKhau))
         {
             string mahoaPass = MaHoa.Instance.Encrypt(acc.MatKhau);
             acc.MatKhau = mahoaPass;
         }
         SetGender(acc.GioiTinh);
         var result = dao.UpdateCustomer(acc);
         if (result)
         {
             SetAlert("Chỉnh sửa người dùng thành công", "success");
             return(RedirectToAction("Index", "QTCustomer"));
         }
         else
         {
             ModelState.AddModelError("", "Chỉnh sửa người dùng thất bại");
         }
     }
     return(View("Index"));
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                CustomerDTO obj = new CustomerDTO();
                obj.ID             = -1;
                obj.Name           = txtName.Text;
                obj.Phone          = txtPhone.Text;
                obj.Address        = txtAddress.Text;
                obj.Description    = txtDescription.Text;
                obj.AbilityRent    = chkAbilityRent.Checked;
                obj.IDBranchOffice = Convert.ToInt64((cboBranchOffice.SelectedItem as clsComboItem).Value);

                ds = CustomerDAO.Customer_InsUpd(obj);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]) == 1)
                {
                    clsMessages.ShowInformation("Thêm thành công!");
                    frmParent.LoadDataToForm();
                    this.Close();
                }
                else
                {
                    clsMessages.ShowWarning("Thêm thất bại!");
                }
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
            }
        }
        public void AddNullCustomerException()
        {
            CustomerDAO dao = new CustomerDAO();

            dao.AddCustomer(null);
        }
Beispiel #14
0
        /// <summary> Retrieves Entity rows in a datatable which match the specified filter. It will always create a new connection to the database.</summary>
        /// <param name="selectFilter">A predicate or predicate expression which should be used as filter for the entities to retrieve.</param>
        /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param>
        /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
        /// <param name="relations">The set of relations to walk to construct to total query.</param>
        /// <param name="pageNumber">The page number to retrieve.</param>
        /// <param name="pageSize">The page size of the page to retrieve.</param>
        /// <returns>DataTable with the rows requested.</returns>
        public static DataTable GetMultiAsDataTable(IPredicate selectFilter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, int pageNumber, int pageSize)
        {
            CustomerDAO dao = DAOFactory.CreateCustomerDAO();

            return(dao.GetMultiAsDataTable(maxNumberOfItemsToReturn, sortClauses, selectFilter, relations, pageNumber, pageSize));
        }
Beispiel #15
0
 public void UpdateConnection()
 {
     this.userDao     = new UserDAO();
     this.customerDao = new CustomerDAO();
 }
Beispiel #16
0
 public CustomerBUS()
 {
     ctmDao = new CustomerDAO();
 }
Beispiel #17
0
 public static List <KhachHangDTO> DSKHDiaChiLoaiKhachCMND(KhachHangDTO thongtin)
 {
     return(CustomerDAO.DSKHDiaChiLoaiKhachCMND(thongtin));
 }
Beispiel #18
0
 public UserManager()
 {
     this.userDao     = new UserDAO();
     this.customerDao = new CustomerDAO();
 }
    private void GenerateReport()
    {
        try
        {

            DataSet dsCustReport = new DataSet();
            CustomerSearch supSearch = new CustomerSearch();
            supSearch.FromDate = dtpFromDate.Date;
            supSearch.ToDate = dtpToDate.Date;
            supSearch.CustId = Int32.Parse(ddlCustomers.SelectedValue.ToString());
            dsCustReport = new CustomerDAO().GetTransactionHistoryByCustomer(supSearch);

            Session["CustomerFullReport"] = dsCustReport;
            BindGrid();
        }
        catch (Exception ex)
        {

            throw ex;
        }
    }
Beispiel #20
0
 public static List <KhachHangDTO> DSKHTheoTenCMND(KhachHangDTO thongtin)
 {
     return(CustomerDAO.DSKHTheoTenCMND(thongtin));
 }
Beispiel #21
0
 public static bool UpdateCus(Customer cus, int idBooking)
 {
     return(CustomerDAO.UpdateCus(cus, idBooking));
 }
Beispiel #22
0
        /// <summary>
        /// 修改出库单数据
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateOutWarehouseBill(OutWarehouseBill bill, List <OutWarehouseBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        //修改出库单数据
                        if (!dao.UpdateOutWarehouseBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //修改出库货物数据
                        foreach (OutWarehouseBillGoods goods in listGoods)
                        {
                            if (!dao.UpdateOutWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }

                    using (CustomerDAO dao = new CustomerDAO())
                    {
                        //修改上力支费价格数据
                        List <CustomerForceFeePrice> listForceFeePrice = dao.LoadCustomerForceFeePricesByCustomerId(bill.CustomerId, nOpStaffId, strOpStaffName, out strErrText);
                        if (listForceFeePrice.Count == 0)
                        {
                            //新增力支费价格数据
                            CustomerForceFeePrice data = new CustomerForceFeePrice();
                            data.CustomerId             = bill.CustomerId;
                            data.StartTime              = bill.CreateTime;
                            data.EndTime                = DateTime.Parse("9999-12-31");
                            data.LoadingForceFeePrice   = bill.LoadingForceFeePrice;
                            data.UnloadingForceFeePrice = 0;

                            if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            int i = 0;
                            while (i < listForceFeePrice.Count)
                            {
                                if (bill.CreateTime.Date >= listForceFeePrice[i].StartTime.Date && bill.CreateTime.Date <= listForceFeePrice[i].EndTime.Date)
                                {
                                    break;
                                }
                                i++;
                            }
                            if (i < listForceFeePrice.Count)
                            {
                                //修改力支费价格数据
                                listForceFeePrice[i].LoadingForceFeePrice = bill.LoadingForceFeePrice;

                                if (!dao.UpdateCustomerForceFeePrice(listForceFeePrice[i], nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                //新增力支费价格数据
                                CustomerForceFeePrice data = new CustomerForceFeePrice();
                                data.CustomerId             = bill.CustomerId;
                                data.StartTime              = bill.CreateTime;
                                data.LoadingForceFeePrice   = bill.LoadingForceFeePrice;
                                data.UnloadingForceFeePrice = 0;

                                //计算截止时间
                                i = 0;
                                while (i < listForceFeePrice.Count)
                                {
                                    if (bill.CreateTime.Date < listForceFeePrice[i].StartTime.Date)
                                    {
                                        break;
                                    }
                                    i++;
                                }
                                if (i < listForceFeePrice.Count)
                                {
                                    data.EndTime = listForceFeePrice[i].StartTime.Date.AddDays(-1);
                                }
                                else
                                {
                                    data.EndTime = DateTime.Parse("9999-12-31");
                                }

                                if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Beispiel #23
0
 public static IEnumerable <Customer> GetAllCus()
 {
     return(CustomerDAO.GetAllCus());
 }
    private void LoadInitialData()
    {
        try
        {
            if (ObjVoucher.DsVoucherDetails == null || ObjVoucher.DsVoucherDetails.Tables.Count == 0 || ObjVoucher.DsVoucherDetails.Tables[0].Rows.Count < 1)
            {
                //
                // PO
                //
                DataSet dsPO = (new PODAO()).GetAllPayablePOs();
                if (dsPO != null && dsPO.Tables.Count != 0)
                {
                    dxgvPODetails.DataSource = dsPO;
                    dxgvPODetails.DataBind();
                    Session["VoucherPOList"] = dsPO;
                }
            }
            else
            {
                dxgvPODetails.Columns[0].Visible = false;
            }

            //
            // Suppliers
            //
            DataSet dsSuppliers = (new SupplierDAO()).GetAllSuppliers();
            if (dsSuppliers == null || dsSuppliers.Tables.Count == 0)
            {
                ddlSuppliers.Items.Add(new ListItem("--No Records--", "-1"));
            }
            else
            {
                Master.BindDropdown("SupplierName", "SupId", dsSuppliers, ddlSuppliers);
                ddlSuppliers.Items.Add(new ListItem("--Please Select--", "-1"));
                ddlSuppliers.SelectedValue = "-1";
            }

            //
            // Fill Customer Code
            //
            DataSet dsCustomers = new CustomerDAO().GetAllCustomers();
            if (dsCustomers == null || dsCustomers.Tables.Count == 0)
            {
                ddlCustomer.Items.Add(new ListItem("--No Data Found--", "-1"));
            }
            else
            {
                Master.BindDropdown("Cus_Name", "CustomerID", dsCustomers, ddlCustomer);
                ddlCustomer.Items.Add(new ListItem("--Please Select--", "-1"));
                ddlCustomer.SelectedValue = "-1";
            }

            //
            // Add Branch
            //
            DataSet dsRoles = (new LocationsDAO()).GetAllBranches();
            if (dsRoles == null || dsRoles.Tables.Count == 0)
            {
                ddlBranch.Items.Add(new ListItem("--No Records--", "-1"));
            }
            else
            {
                Master.BindDropdown("BranchCode", "BranchId", dsRoles, ddlBranch);
                ddlBranch.Items.Add(new ListItem("--Please Select--", "-1"));
                ddlBranch.SelectedValue = "-1";
            }

            //
            // Add Branch
            //
            DataSet dsCheques = (new ChequeBookDAO()).GetAllAvailableCheques();
            if (dsRoles == null || dsRoles.Tables.Count == 0)
            {
                ddlChequeNumbers.Items.Add(new ListItem("--No Records--", "-1"));
            }
            else
            {
                Master.BindDropdown("ChequeNo", "ChqId", dsCheques, ddlChequeNumbers);
                ddlChequeNumbers.Items.Add(new ListItem("--Please Select--", "-1"));
                ddlChequeNumbers.SelectedValue = "-1";
            }

            this.LoadAccountTypes();
        }
        catch (Exception ex)
        {

            throw ex;
        }
    }
Beispiel #25
0
 public CustomerBLL()
 {
     _customerDAO = new CustomerDAO();
 }
Beispiel #26
0
 public CustomerBUS()
 {
     _customerDAO = new CustomerDAO();
 }
    private void Search()
    {
        try
        {
            DataSet searchCus = new CustomerDAO().GetAllCustomers();
            dxgvCustomers.DataSource = searchCus;
            Session["SearchCustomers"] = searchCus;
            dxgvCustomers.DataBind();
        }
        catch (Exception ex)
        {

            throw ex;
        }
    }
        public List <Customer> ListCustomers()
        {
            var customerDao = new CustomerDAO();

            return(customerDao.ListCustomers());
        }
    private void LoadInitialData()
    {
        try
        {
            if (ObjVoucher.DsVoucherDetails == null || ObjVoucher.DsVoucherDetails.Tables.Count == 0 || ObjVoucher.DsVoucherDetails.Tables[0].Rows.Count < 1)
            {

                //
                // PO
                //
                DataSet dsPO = (new PODAO()).GetAllPayablePOs();
                if (dsPO != null && dsPO.Tables.Count != 0)
                {
                    dxgvPODetails.DataSource = dsPO;
                    dxgvPODetails.DataBind();
                    Session["VoucherPOList"] = dsPO;
                }
            }
            else
            {
                //dxgvPODetails.Columns[0].Visible = false;
            }

            //
            // Suppliers
            //
            DataSet dsSuppliers = (new SupplierDAO()).GetAllSuppliers();
            if (dsSuppliers == null || dsSuppliers.Tables.Count == 0)
            {
                ddlSuppliers.Items.Add(new ListItem("--No Records--", "-1"));
            }
            else
            {
                ddlSuppliers.DataSource = dsSuppliers;
                ddlSuppliers.DataTextField = "SupplierName";
                ddlSuppliers.DataValueField = "SupId";
                ddlSuppliers.DataBind();
                //ddlSuppliers.Items.Add(new ListItem("--Please Select--", "-1"));
                //ddlSuppliers.SelectedValue = "-1";
            }

            //
            // Fill Customer Code
            //
            DataSet dsCustomers = new CustomerDAO().GetAllCustomers();
            if (dsCustomers == null || dsCustomers.Tables.Count == 0)
            {
                ddlCustomer.Items.Add(new ListItem("--No Data Found--", "-1"));
            }
            else
            {
                ddlCustomer.DataSource = dsCustomers;
                ddlCustomer.DataTextField = "Cus_Name";
                ddlCustomer.DataValueField = "CustomerID";
                ddlCustomer.DataBind();
                //ddlCustomer.Items.Add(new ListItem("--Please Select--", "-1"));
                //ddlCustomer.SelectedValue = "-1";
            }

            this.LoadAccountTypes();
        }
        catch (Exception ex)
        {

            throw ex;
        }
    }
        private void InitDataGridView()
        {
            DataTable dt = CustomerDAO.GetDataOfCustomerRela(this.custid);

            (new InitFuncs()).InitDataGridView(this.dataGridViewcustrela, dt);
        }
    private void LoadInitialData()
    {
        try
        {
            //lblDate.Text = DateTime.Now.ToShortDateString();
            dpDate.Date = DateTime.Now;

            //
            // Fill Customer Code
            //
            DataSet dsCustomers = new CustomerDAO().GetAllCustomers();
            if (dsCustomers == null || dsCustomers.Tables.Count == 0)
            {
                ddlCustomerCode.Items.Add(new ListItem("--No Data Found--", "-1"));
            }
            else
            {
                Master.BindDropdown("Cus_Name", "CustomerID", dsCustomers, ddlCustomerCode);
                ddlCustomerCode.Items.Add(new ListItem("--Please Select--", "-1"));
                ddlCustomerCode.SelectedValue = "-1";
            }

            //
            // Fill the discount dropdown
            //
            int max = Convert.ToInt32(Constant.MaximumDiscountAllowed_Invoice.Trim());
            decimal increment = Convert.ToDecimal(Constant.Increment_Seed.Trim());
            if (ddlDiscount.Items.Count == 0)
            {
                for (decimal i = 0.00M; i < max; )
                {
                    ddlDiscount.Items.Add(new ListItem(i.ToString(), i.ToString()));
                    i = i + increment;
                }
            }

            //
            // If currently logged user is not admin cannot update paid amounts
            //
            if (hdnInvId.Value != "0")
            {
                if (Master.LoggedUser.UserRoleID > 1)
                {
                    txtPaidAmount.ReadOnly = true;
                }
            }

            //
            // Fill the user name
            //
            DataSet dsUsers = new UsersDAO().GetAllUsers();
            if (dsUsers == null || dsUsers.Tables.Count == 0)
            {
                ddlInvoicedBy.Items.Add(new ListItem("--No Records--", "-1"));
            }
            else
            {
                Master.BindDropdown("FirstName", "UserId", dsUsers, ddlInvoicedBy);
            }
        }
        catch (Exception ex)
        {

            throw ex;
        }
    }
Beispiel #32
0
 public static int CreateCus(Customer cus)
 {
     return(CustomerDAO.CreateCus(cus));
 }
Beispiel #33
0
 public CustomerBUS()
 {
     ctDao = new CustomerDAO();
 }
Beispiel #34
0
 public static Customer GetCusByID(int id)
 {
     return(CustomerDAO.GetCusByID(id));
 }
    private void LoadInitialData()
    {
        try
        {

            //
            // Fill Customer Code
            //
            DataSet dsCustomers = new CustomerDAO().GetAllCustomers();
            if (dsCustomers == null || dsCustomers.Tables.Count == 0)
            {
                ddlCustomerCode.Items.Add(new ListItem("--No Data Found--", "-1"));
            }
            else
            {
                Master.BindDropdown("Cus_Name", "CustomerID", dsCustomers, ddlCustomerCode);
                ddlCustomerCode.Items.Add(new ListItem("--Please Select--", "-1"));
                ddlCustomerCode.SelectedValue = "-1";
            }

        }
        catch (Exception ex)
        {

            throw ex;
        }
    }
Beispiel #36
0
        /// <summary>
        /// 修改入库单数据
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateEnterWarehouseBill(EnterWarehouseBill bill, List <EnterWarehouseBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        //读取原入库单货物数据
                        List <EnterWarehouseBillGoods> listOldGoods = dao.LoadEnterWarehouseBillAllGoods(bill.Id, nOpStaffId, strOpStaffName, out strErrText);
                        if (listOldGoods == null)
                        {
                            return(false);
                        }

                        //如果划拨计划所产生的入库单,则修改前必须检查新旧货物的数量
                        if (bill.PlanId > 0)
                        {
                            //检查每个品种数据
                            var grpOldGoods = listOldGoods.GroupBy(g => new { g.GoodsNo, g.BatchNo, g.Packing, g.ProductionDate, g.EnterWarehouseBillId });
                            foreach (var grpOld in grpOldGoods)
                            {
                                string  strGoodsNo            = grpOld.Key.GoodsNo;
                                string  strBatchNo            = grpOld.Key.BatchNo;
                                string  strPacking            = grpOld.Key.Packing;
                                string  strProductionDate     = grpOld.Key.ProductionDate;
                                long    nEnterWarehouseBillId = grpOld.Key.EnterWarehouseBillId;
                                int     nOldTotalPackages     = grpOld.Sum(s => s.Packages);
                                decimal decOldTotalTunnages   = grpOld.Sum(s => s.Tunnages);

                                List <EnterWarehouseBillGoods> listNew = listGoods.Where(g => g.GoodsNo == strGoodsNo && g.BatchNo == strBatchNo && (g.Packing ?? string.Empty) == strPacking && g.ProductionDate == strProductionDate && g.EnterWarehouseBillId == nEnterWarehouseBillId).ToList();
                                if (nOldTotalPackages != listNew.Sum(g => g.Packages) || decOldTotalTunnages != listNew.Sum(g => g.Tunnages))
                                {
                                    strErrText = string.Format(InnoSoft.LS.Resources.Strings.GoodsModifyBeforeAndAfterPackagesOrTunnagesNotEqual, strGoodsNo, strBatchNo, strPacking, strProductionDate);
                                    return(false);
                                }
                            }

                            //检查总数量
                            if (listGoods.Sum(g => g.Packages) != listOldGoods.Sum(g => g.Packages) || listGoods.Sum(g => g.Tunnages) != listOldGoods.Sum(g => g.Tunnages))
                            {
                                strErrText = InnoSoft.LS.Resources.Strings.GoodsModifyBeforeAndAfterTotalPackagesOrTotalTunnagesNotEqual;
                                return(false);
                            }
                        }

                        //新增入库货物数据
                        foreach (EnterWarehouseBillGoods goods in listGoods)
                        {
                            if (goods.Id == 0)
                            {
                                if (!dao.InsertEnterWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }

                        //修改入库货物数据
                        foreach (EnterWarehouseBillGoods goods in listGoods)
                        {
                            if (goods.Id > 0)
                            {
                                if (!dao.UpdateEnterWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }

                        //删除入库单货物数据
                        foreach (EnterWarehouseBillGoods o in listOldGoods)
                        {
                            if (listGoods.FindAll(delegate(EnterWarehouseBillGoods g) { return(g.Id == o.Id); }).Count == 0)
                            {
                                if (!dao.DeleteEnterWarehouseBillGoods(o.Id, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }

                        //修改入库单数据
                        if (!dao.UpdateEnterWarehouseBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }

                    using (CustomerDAO dao = new CustomerDAO())
                    {
                        //修改下力支费价格数据
                        List <CustomerForceFeePrice> listForceFeePrice = dao.LoadCustomerForceFeePricesByCustomerId(bill.CustomerId, nOpStaffId, strOpStaffName, out strErrText);
                        if (listForceFeePrice.Count == 0)
                        {
                            //新增力支费价格数据
                            CustomerForceFeePrice data = new CustomerForceFeePrice();
                            data.CustomerId             = bill.CustomerId;
                            data.StartTime              = bill.CreateTime;
                            data.EndTime                = DateTime.Parse("9999-12-31");
                            data.LoadingForceFeePrice   = 0;
                            data.UnloadingForceFeePrice = bill.UnloadingForceFeePrice;

                            if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            int i = 0;
                            while (i < listForceFeePrice.Count)
                            {
                                if (bill.CreateTime.Date >= listForceFeePrice[i].StartTime.Date && bill.CreateTime.Date <= listForceFeePrice[i].EndTime.Date)
                                {
                                    break;
                                }
                                i++;
                            }
                            if (i < listForceFeePrice.Count)
                            {
                                //修改力支费价格数据
                                listForceFeePrice[i].UnloadingForceFeePrice = bill.UnloadingForceFeePrice;

                                if (!dao.UpdateCustomerForceFeePrice(listForceFeePrice[i], nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                //新增力支费价格数据
                                CustomerForceFeePrice data = new CustomerForceFeePrice();
                                data.CustomerId             = bill.CustomerId;
                                data.StartTime              = bill.CreateTime;
                                data.LoadingForceFeePrice   = 0;
                                data.UnloadingForceFeePrice = bill.UnloadingForceFeePrice;

                                //计算截止时间
                                i = 0;
                                while (i < listForceFeePrice.Count)
                                {
                                    if (bill.CreateTime.Date < listForceFeePrice[i].StartTime.Date)
                                    {
                                        break;
                                    }
                                    i++;
                                }
                                if (i < listForceFeePrice.Count)
                                {
                                    data.EndTime = listForceFeePrice[i].StartTime.Date.AddDays(-1);
                                }
                                else
                                {
                                    data.EndTime = DateTime.Parse("9999-12-31");
                                }

                                if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }

                        //修改仓储费价格数据
                        List <CustomerStorageFeePrice> listStorageFeePrice = dao.LoadCustomerStorageFeePricesByCustomerId(bill.CustomerId, nOpStaffId, strOpStaffName, out strErrText);
                        if (listStorageFeePrice.Count == 0)
                        {
                            //新增仓储费价格数据
                            CustomerStorageFeePrice data = new CustomerStorageFeePrice();
                            data.CustomerId      = bill.CustomerId;
                            data.StartTime       = bill.CreateTime;
                            data.EndTime         = DateTime.Parse("9999-12-31");
                            data.StorageFeePrice = bill.StorageFeePrice;

                            if (!dao.InsertCustomerStorageFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            int i = 0;
                            while (i < listStorageFeePrice.Count)
                            {
                                if (bill.CreateTime.Date >= listStorageFeePrice[i].StartTime.Date && bill.CreateTime.Date <= listStorageFeePrice[i].EndTime.Date)
                                {
                                    break;
                                }
                                i++;
                            }
                            if (i < listStorageFeePrice.Count)
                            {
                                //修改仓储费价格数据
                                listStorageFeePrice[i].StorageFeePrice = bill.StorageFeePrice;

                                if (!dao.UpdateCustomerStorageFeePrice(listStorageFeePrice[i], nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                //新增仓储费价格数据
                                CustomerStorageFeePrice data = new CustomerStorageFeePrice();
                                data.CustomerId      = bill.CustomerId;
                                data.StartTime       = bill.CreateTime;
                                data.StorageFeePrice = bill.StorageFeePrice;

                                //计算截止时间
                                i = 0;
                                while (i < listStorageFeePrice.Count)
                                {
                                    if (bill.CreateTime.Date < listStorageFeePrice[i].StartTime.Date)
                                    {
                                        break;
                                    }
                                    i++;
                                }
                                if (i < listStorageFeePrice.Count)
                                {
                                    data.EndTime = listStorageFeePrice[i].StartTime.Date.AddDays(-1);
                                }
                                else
                                {
                                    data.EndTime = DateTime.Parse("9999-12-31");
                                }

                                if (!dao.InsertCustomerStorageFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Beispiel #37
0
 public static List <KhachHangDTO> DSKHTheoPhong(PhongDTO thongtin)
 {
     return(CustomerDAO.DSKHTheoPhong(thongtin));
 }
Beispiel #38
0
        public Customer GetCustomerById(string custId)
        {
            CustomerDAO dao = new CustomerDAO();

            return(dao.SelectById(custId));
        }
    private void LoadInitialData()
    {
        try
        {

            //
            // Fill Customer Code
            //
            DataSet dsCustomers = new CustomerDAO().GetAllCustomers();
            if (dsCustomers == null || dsCustomers.Tables.Count == 0)
            {
                ddlCustomerCode.Items.Add(new ListItem("--No Data Found--", "-1"));
            }
            else
            {
                ddlCustomerCode.DataSource = dsCustomers;
                ddlCustomerCode.DataTextField = "Cus_Name";
                ddlCustomerCode.DataValueField = "CustomerID";
                ddlCustomerCode.DataBind();
                //ddlCustomerCode.Items.Add(new ListItem("--Please Select--", "-1"));
                //ddlCustomerCode.SelectedValue = "-1";
            }

        }
        catch (Exception ex)
        {

            throw ex;
        }
    }