Ejemplo n.º 1
0
        public JsonResult LoadCustomers()
        {
            string strErrText = string.Empty;
            CustomerSystem customer = new CustomerSystem();
            List<Customer> listCustomer = customer.LoadCustomers(LoginAccountId, LoginStaffName, out strErrText);
            if (listCustomer == null)
            {
                throw new Exception(strErrText);
            }

            var ret = from c in listCustomer
                      select new
                      {
                          c.Id,
                          c.Name
                      };

            return Json(ret, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 2
0
        public ActionResult ExportCustomers()
        {
            string strErrText;

            //读取全部数据
            CustomerSystem customer = new CustomerSystem();
            List<Customer> listCustomer = customer.LoadCustomers(LoginAccountId, LoginStaffName, out strErrText);
            if (listCustomer == null)
            {
                throw new Exception(strErrText);
            }

            //生成GridView
            BoundField colCustomerId = new BoundField();
            colCustomerId.HeaderText = InnoSoft.LS.Resources.Labels.CustomerId;
            colCustomerId.DataField = "CustomerId";

            BoundField colName = new BoundField();
            colName.HeaderText = InnoSoft.LS.Resources.Labels.CustomerName;
            colName.DataField = "Name";

            BoundField colFullName = new BoundField();
            colFullName.HeaderText = InnoSoft.LS.Resources.Labels.CustomerFullName;
            colFullName.DataField = "FullName";

            BoundField colWarningStock = new BoundField();
            colWarningStock.HeaderText = InnoSoft.LS.Resources.Labels.WarningStock;
            colWarningStock.DataField = "WarningStock";

            BoundField colStopStock = new BoundField();
            colStopStock.HeaderText = InnoSoft.LS.Resources.Labels.StopStock;
            colStopStock.DataField = "StopStock";

            BoundField colSettlementExpression = new BoundField();
            colSettlementExpression.HeaderText = InnoSoft.LS.Resources.Labels.SettlementExpression;
            colSettlementExpression.DataField = "SettlementExpression";

            BoundField colValuationMode = new BoundField();
            colValuationMode.HeaderText = InnoSoft.LS.Resources.Labels.ValuationMode;
            colValuationMode.DataField = "ValuationMode";

            BoundField colGrossWeightRate = new BoundField();
            colGrossWeightRate.HeaderText = InnoSoft.LS.Resources.Labels.GrossWeightRate;
            colGrossWeightRate.DataField = "GrossWeightRate";

            BoundField colOwnOrganId = new BoundField();
            colOwnOrganId.HeaderText = InnoSoft.LS.Resources.Labels.OwnOrganId;
            colOwnOrganId.DataField = "OwnOrganId";

            BoundField colOwnOrganName = new BoundField();
            colOwnOrganName.HeaderText = InnoSoft.LS.Resources.Labels.OwnOrganName;
            colOwnOrganName.DataField = "OwnOrganName";

            BoundField colRemark = new BoundField();
            colRemark.HeaderText = InnoSoft.LS.Resources.Labels.Remark;
            colRemark.DataField = "Remark";

            var grid = new GridView();
            grid.Columns.Add(colCustomerId);
            grid.Columns.Add(colName);
            grid.Columns.Add(colFullName);
            grid.Columns.Add(colWarningStock);
            grid.Columns.Add(colStopStock);
            grid.Columns.Add(colSettlementExpression);
            grid.Columns.Add(colValuationMode);
            grid.Columns.Add(colGrossWeightRate);
            grid.Columns.Add(colOwnOrganId);
            grid.Columns.Add(colOwnOrganName);
            grid.Columns.Add(colRemark);

            grid.AutoGenerateColumns = false;

            grid.DataSource = from c in listCustomer
                              select new
                              {
                                  CustomerId = c.Id,
                                  Name = c.Name,
                                  FullName = c.FullName,
                                  WarningStock = c.WarningStock > 0 ? c.WarningStock.ToString() : string.Empty,
                                  StopStock = c.StopStock > 0 ? c.StopStock.ToString() : string.Empty,
                                  SettlementExpression = c.SettlementExpression,
                                  ValuationMode = c.ValuationMode,
                                  GrossWeightRate = c.GrossWeightRate > 0 ? c.GrossWeightRate.ToString("#0.######") : string.Empty,
                                  OwnOrganId = c.OwnOrganId,
                                  OwnOrganName = c.OwnOrganName,
                                  Remark = c.Remark
                              };
            grid.DataBind();

            //导出GridView
            Response.ClearContent();
            Response.Charset = InnoSoft.LS.Resources.Encoding.ExcelCharset;
            Response.ContentEncoding = System.Text.Encoding.GetEncoding(InnoSoft.LS.Resources.Encoding.ExcelContent);
            Response.ContentType = "application/ms-excel";
            Response.Write("<meta http-equiv=Content-Type content=text/html charset=" + InnoSoft.LS.Resources.Encoding.ExcelCharset + ">");
            Response.AddHeader("content-disposition", "attachment; filename=Customer.xls");
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            grid.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();

            return View("SetCustomer");
        }
Ejemplo n.º 3
0
        public JsonResult LoadCustomerFullNames(string term)
        {
            //读取所有客户数据
            string strErrText = string.Empty;
            CustomerSystem customer = new CustomerSystem();
            List<Customer> listCustomer = customer.LoadCustomers(LoginAccountId, LoginStaffName, out strErrText);
            if (listCustomer == null)
            {
                listCustomer = new List<Customer>();
            }

            //提取客户全称中包含关键字的记录
            var ret = (
                from c in listCustomer
                where c.FullName.Contains(term)
                select c.FullName).ToArray();

            return Json(ret, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 4
0
        public ActionResult ModifyAccount(string id)
        {
            string strErrText;

            //生成Model数据
            long nAccountId = long.Parse(id);
            AuthenticateSystem auth = new AuthenticateSystem();
            Account data = auth.LoadAccount(nAccountId, LoginAccountId, LoginStaffName, out strErrText);
            if (data == null)
            {
                throw new Exception(strErrText);
            }

            AccountViewModel model = new AccountViewModel();
            model.Id = data.Id;
            model.Name = data.Name;
            model.Password = data.Password;
            model.AccountType = data.AccountType;
            model.OrganId = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? data.OrganId : 0;
            model.StaffId = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? data.StaffId : 0;
            model.CustomerId = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? 0 : data.OrganId;
            model.ContactName = data.AccountType == InnoSoft.LS.Resources.Options.Staff ? string.Empty : data.StaffName;
            model.IsCancel = data.IsCancel;

            if (data.AccountType == InnoSoft.LS.Resources.Options.Staff)
            {
                //生成组织部门下拉列表
                OrganizationSystem organ = new OrganizationSystem();
                List<Organization> listOrganization = organ.LoadOrganizations(LoginAccountId, LoginStaffName, out strErrText);
                if (listOrganization == null)
                {
                    throw new Exception(strErrText);
                }
                List<SelectListItem> selectListOrganization = new List<SelectListItem>();
                selectListOrganization.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                selectListOrganization.AddRange(from o in listOrganization
                                                orderby o.FullName
                                                select new SelectListItem
                                                {
                                                    Text = o.FullName,
                                                    Value = o.Id.ToString()
                                                });
                ViewData["Organizations"] = new SelectList(selectListOrganization, "Value", "Text", model.OrganId);

                //生成空的客户下拉列表
                List<Customer> listCustomer = new List<Customer>();
                List<SelectListItem> selectListCustomer = new List<SelectListItem>();
                selectListCustomer.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                selectListCustomer.AddRange(from c in listCustomer
                                            select new SelectListItem
                                            {
                                                Text = c.Name,
                                                Value = c.Id.ToString()
                                            });
                ViewData["Customers"] = new SelectList(selectListCustomer, "Value", "Text");
            }
            else
            {
                //生成空的组织部门下拉列表
                {
                    List<Organization> listOrganization = new List<Organization>();
                    List<SelectListItem> selectListOrganization = new List<SelectListItem>();
                    selectListOrganization.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                    selectListOrganization.AddRange(from o in listOrganization
                                                    select new SelectListItem
                                                    {
                                                        Text = o.FullName,
                                                        Value = o.Id.ToString()
                                                    });
                    ViewData["Organizations"] = new SelectList(selectListOrganization, "Value", "Text");
                }

                //生成客户下拉列表
                CustomerSystem customer = new CustomerSystem();
                List<Customer> listCustomer = customer.LoadCustomers(LoginAccountId, LoginStaffName, out strErrText);
                if (listCustomer == null)
                {
                    throw new Exception(strErrText);
                }
                List<SelectListItem> selectListCustomer = new List<SelectListItem>();
                selectListCustomer.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                selectListCustomer.AddRange(from c in listCustomer
                                            orderby c.Name
                                            select new SelectListItem
                                            {
                                                Text = c.Name,
                                                Value = c.Id.ToString()
                                            });
                ViewData["Customers"] = new SelectList(selectListCustomer, "Value", "Text", model.OrganId);
            }

            //生成员工下拉列表
            if (data.AccountType == InnoSoft.LS.Resources.Options.Staff)
            {
                StaffSystem staff = new StaffSystem();
                List<Staff> listStaff = staff.LoadStaffsByOrganId(model.OrganId, LoginAccountId, LoginStaffName, out strErrText);
                if (listStaff == null)
                {
                    throw new Exception(strErrText);
                }
                List<SelectListItem> selectListStaff = new List<SelectListItem>();
                selectListStaff.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                selectListStaff.AddRange(from s in listStaff
                                         select new SelectListItem
                                         {
                                             Text = s.FullName,
                                             Value = s.Id.ToString()
                                         });

                ViewData["Staffs"] = new SelectList(selectListStaff, "Value", "Text", model.StaffId);
            }
            else
            {
                List<Staff> listStaff = new List<Staff>();
                List<SelectListItem> selectListStaff = new List<SelectListItem>();
                selectListStaff.Add(new SelectListItem { Text = string.Empty, Value = "0" });
                selectListStaff.AddRange(from s in listStaff
                                         select new SelectListItem
                                         {
                                             Text = s.Name,
                                             Value = s.Id.ToString()
                                         });
                ViewData["Staffs"] = new SelectList(selectListStaff, "Value", "Text");
            }

            return View(model);
        }