예제 #1
0
        /// <summary>
        /// 加载新增Panel中的dropdownlist数据
        /// </summary>
        void LoadNewPanelDropDownList()
        {
            //绑定层位类型
            List <NameValueModel> ListBinType = Gold.Utility.EnumData.GetEnumsList(typeof(Gold.Utility.EnumData.BinTypeEnum));

            dropdownList_NewBinType.Items.Clear();
            dropdownList_NewBinType.DataTextField  = "Name";
            dropdownList_NewBinType.DataValueField = "Value";
            dropdownList_NewBinType.DataSource     = ListBinType;
            dropdownList_NewBinType.DataBind();

            //绑定标签状态
            List <NameValueModel> ListBinTagStatus = Gold.Utility.EnumData.GetEnumsList(typeof(Gold.Utility.EnumData.BinTagStatusEnum));

            dropdownList_NewBinTagStatus.Items.Clear();
            dropdownList_NewBinTagStatus.DataTextField  = "Name";
            dropdownList_NewBinTagStatus.DataValueField = "Value";
            dropdownList_NewBinTagStatus.DataSource     = ListBinTagStatus;
            dropdownList_NewBinTagStatus.DataBind();

            using (GoldEntities context = new GoldEntities())
            {
                var result = (from r in context.WareHouse select new { r.WHCode, r.WHName }).OrderBy(r => r.WHCode).ToList();
                dropdownList_NewWareHouse.Items.Clear();
                dropdownList_NewWareHouse.DataTextField  = "WHName";
                dropdownList_NewWareHouse.DataValueField = "WHCode";
                dropdownList_NewWareHouse.DataSource     = result;
                dropdownList_NewWareHouse.DataBind();
            }
        }
예제 #2
0
        /// <summary>
        /// 加载dropdownlist数据
        /// </summary>
        void LoadNewPanelDropDownList()
        {
            using (GoldEntities context = new GoldEntities())
            {
                //绑定盘点计划单状态
                List <NameValueModel> ListStatus = Gold.Utility.EnumData.GetEnumsList(typeof(Gold.Utility.EnumData.SCPStatusEnum));
                DropDownList_SCPStatus.Items.Clear();
                DropDownList_SCPStatus.DataTextField  = "Name";
                DropDownList_SCPStatus.DataValueField = "Value";
                DropDownList_SCPStatus.DataSource     = ListStatus;
                DropDownList_SCPStatus.DataBind();
                DropDownList_SCPStatus.Items.Insert(0, new ListItem("", ""));

                //绑定盘点计划单状态
                List <NameValueModel> ListType = Gold.Utility.EnumData.GetEnumsList(typeof(Gold.Utility.EnumData.SCPTypeEnum));
                DropDownList_Type.Items.Clear();
                DropDownList_Type.DataTextField  = "Name";
                DropDownList_Type.DataValueField = "Value";
                DropDownList_Type.DataSource     = ListType;
                DropDownList_Type.DataBind();
                DropDownList_Type.Items.Insert(0, new ListItem("", ""));

                //绑定仓库
                var result = (from r in context.WareHouse select new { r.WHCode, r.WHName }).OrderBy(r => r.WHCode).ToList();
                DropDownList_WHCode.Items.Clear();
                DropDownList_WHCode.DataTextField  = "WHName";
                DropDownList_WHCode.DataValueField = "WHCode";
                DropDownList_WHCode.DataSource     = result;
                DropDownList_WHCode.DataBind();
                DropDownList_WHCode.Items.Insert(0, new ListItem("", ""));
            }
        }
예제 #3
0
        // 添加自定义的值,然后导航到来到此页面之前的位置
        private void SetUserDataAndRedirect(string userId)
        {
            //存储用户基本信息到Session
            using (var edm = new GoldEntities())
            {
                Users userInfo = edm.Users.SingleOrDefault(o => o.UserId == userId);
                Session["UserInfo"] = userInfo;
                Session["UserName"] = userInfo.UserName;
            }

            // 获得Cookie
            HttpCookie authCookie = FormsAuthentication.GetAuthCookie(userId, true);

            // 得到ticket凭据
            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);

            // 根据之前的ticket凭据创建新ticket凭据,然后加入自定义信息
            FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(
                ticket.Version, ticket.Name, ticket.IssueDate,
                ticket.Expiration, ticket.IsPersistent, "");

            // 将新的Ticke转变为Cookie值,然后添加到Cookies集合中
            authCookie.Value = FormsAuthentication.Encrypt(newTicket);
            HttpContext.Current.Response.Cookies.Add(authCookie);

            // 获得 来到登录页之前的页面,即url中return参数的值
            string url = FormsAuthentication.GetRedirectUrl(userId, true);

            Response.Redirect(url, false);//增加false参数,防止出现类似"由于代码已经过优化或者本机框架位于调用堆栈之上,无法计算表达式的值"的异常
        }
예제 #4
0
        protected void btnSaveRoot_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtRootCode.Text.Trim()))
            {
                lblrootMessage.Text = "代码不能为空!";
                return;
            }

            if (string.IsNullOrEmpty(txtRootName.Text.Trim()))
            {
                lblrootMessage.Text = "名称不能为空!";
                return;
            }

            using (var edm = new GoldEntities())
            {
                var tmp = edm.CreateObject <DataDict>();
                tmp.Name     = txtRootName.Text.Trim();
                tmp.Code     = txtRootCode.Text.Trim();
                tmp.Category = "root";
                tmp.Enabled  = true;

                edm.AddToDataDict(tmp);
                edm.SaveChanges();

                TreeNode node = new TreeNode();
                node.Value = tmp.Code;
                node.Text  = tmp.Name;
                TreeView1.Nodes.Add(node);

                txtRootCode.Text    = "";
                txtRootName.Text    = "";
                lblrootMessage.Text = "保存成功!";
            }
        }
예제 #5
0
        private void LoadInfo(string ItemID)
        {
            using (GoldEntities context = new GoldEntities())
            {
                //绑定型号
                var allModelList = (from r in context.Models orderby r.ModelName select new { r.ModelId, r.ModelName }).ToList();
                DropDownList_CargoModel.Items.Clear();
                DropDownList_CargoModel.DataTextField  = "ModelName";
                DropDownList_CargoModel.DataValueField = "ModelID";
                DropDownList_CargoModel.DataSource     = allModelList;
                DropDownList_CargoModel.DataBind();
                DropDownList_CargoModel.Items.Insert(0, new ListItem("", ""));

                //绑定规格
                var allSpecList = (from r in context.Specifications orderby r.SpecName select new { r.SpecId, r.SpecName }).ToList();
                DropDownList_CargoSpec.Items.Clear();
                DropDownList_CargoSpec.DataTextField  = "SpecName";
                DropDownList_CargoSpec.DataValueField = "SpecId";
                DropDownList_CargoSpec.DataSource     = allSpecList;
                DropDownList_CargoSpec.DataBind();
                DropDownList_CargoSpec.Items.Insert(0, new ListItem("", ""));

                //绑定可售状态
                List <NameValueModel> ListBinType = Gold.Utility.EnumData.GetEnumsList(typeof(Gold.Utility.EnumData.CargoSaleStatus));
                DropDownList_SaleStatus.Items.Clear();
                DropDownList_SaleStatus.DataTextField  = "Name";
                DropDownList_SaleStatus.DataValueField = "Value";
                DropDownList_SaleStatus.DataSource     = ListBinType;
                DropDownList_SaleStatus.DataBind();


                //编辑状态下进入此页面时
                if (ItemID != "-1")
                {
                    Cargos existModel = (from r in context.Cargos where r.CargoCode == ItemID select r).FirstOrDefault();
                    if (existModel != null)
                    {
                        tbxCargoCode.Text = existModel.CargoCode;
                        tbxCargoName.Text = existModel.CargoName;

                        //设置选中项
                        DropDownList_CargoModel.SelectedIndex = DropDownList_CargoModel.Items.IndexOf(DropDownList_CargoModel.Items.FindByText(existModel.CargoModel.Trim()));
                        DropDownList_CargoSpec.SelectedIndex  = DropDownList_CargoSpec.Items.IndexOf(DropDownList_CargoSpec.Items.FindByText(existModel.CargoSpec.Trim()));

                        tbxUnits.Text = existModel.CargoUnits;
                        tbxYear.Text  = existModel.ProduceYear;

                        DropDownList_SaleStatus.SelectedIndex = DropDownList_SaleStatus.Items.IndexOf(DropDownList_SaleStatus.Items.FindByValue(existModel.SaleStatus == null ? "" : existModel.SaleStatus.Value.ToString()));
                        tbxPrice1.Text = existModel.Price1 == null ? "" : existModel.Price1.Value.ToString();
                        tbxPrice2.Text = existModel.Price2 == null ? "" : existModel.Price2.Value.ToString();
                        tbxPrice3.Text = existModel.Price3 == null ? "" : existModel.Price3.Value.ToString();
                        tbxPrice4.Text = existModel.Price4 == null ? "" : existModel.Price4.Value.ToString();
                        tbxPrice5.Text = existModel.Price5 == null ? "" : existModel.Price5.Value.ToString();

                        tbxComment.Text = existModel.Comment;
                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        /// 新增按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddNew_Click(object sender, EventArgs e)
        {
            if (Page.IsValid == false)
            {
                return;
            }

            try
            {
                lblAddMsg.Text = "";
                string        whCode         = WebConfigHelper.Instance.GetAppSettingValue("DefaultWHCode");
                List <string> checkedDelList = GetCheckItemID();
                if (checkedDelList.Count <= 0)
                {
                    lblAddMsg.Text = "请先选中待设置的项";
                    //ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('请先在列表中选中待设置的项,填写要设置的安全库存量后再点击“保存”按钮');</script>");
                    return;
                }

                using (GoldEntities context = new GoldEntities())
                {
                    foreach (string checkCode in checkedDelList)
                    {
                        CargoSafeInventory existModel = (from r in context.CargoSafeInventory where r.CargoCode.Equals(checkCode) && r.WHCode.Equals(whCode) select r).FirstOrDefault();
                        if (existModel != null)
                        {
                            existModel.SafeInventory = int.Parse(tbxNewSafeNumber.Text);
                        }
                        else
                        {
                            CargoSafeInventory newObj = new CargoSafeInventory();
                            newObj.WHCode        = whCode;
                            newObj.CargoCode     = checkCode;
                            newObj.SafeInventory = int.Parse(tbxNewSafeNumber.Text);

                            context.CargoSafeInventory.AddObject(newObj);
                        }
                    }
                    int affectedRow = context.SaveChanges();
                    if (affectedRow > 0)
                    {
                        lblAddMsg.Text = "保存成功![已保存" + affectedRow.ToString() + "项]";
                    }
                    else
                    {
                        lblAddMsg.Text = "保存失败!";
                    }

                    GridViewBind();//删除后重新绑定数据
                }
            }
            catch (Exception ex)
            {
                lblAddMsg.Text = "保存失败!";
                //lblGridViewMsg.Text = "删除出现异常!详细信息:" + Utility.LogHelper.GetExceptionMsg(ex);
                LogHelper.WriteLog(LogHelper.LogLevel.Error, "安全库存量设置AddNew", ex);
            }
        }
예제 #7
0
        /// <summary>
        /// 根据仓库和商品获取原账面数量
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAccountNumberOld_Click(object sender, EventArgs e)
        {
            if (DropDownList_WHCode.SelectedIndex == 0 || tbxCargoCode.Text == "")
            {
                ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "btnAccountNumberOld_Click_WH", "alert('请先选择仓库和商品!');", true);
                return;
            }
            if (tbxCargoCode.Text.Trim() != "")
            {
                using (GoldEntities context = new GoldEntities())
                {
                    Cargos existModel = (from r in context.Cargos where r.CargoCode == tbxCargoCode.Text.Trim() select r).FirstOrDefault();
                    if (existModel == null)
                    {
                        ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "btnAccountNumberOld_Click_Cargos", "alert('商品编码[" + tbxCargoCode.Text.Trim() + "]在系统中不存在,请先选择正确的商品!');", true);
                        return;
                    }
                }
            }
            string whCode    = DropDownList_WHCode.SelectedItem.Value.ToString();
            string cargoCode = tbxCargoCode.Text.Trim();


            using (GoldEntities context = new GoldEntities())
            {
                //获取之前的余额
                StorePickAccount lastExistModel = null;
                if (ViewState["EditType"].ToString() == "1")//新增
                {
                    lastExistModel = (from r in context.StorePickAccount
                                      orderby r.StockPickAccountID descending
                                      where r.WHCode == whCode && r.CargoCode == cargoCode
                                      select r).FirstOrDefault();
                }
                else //编辑
                {
                    int storePickAccountID = int.Parse(ViewState["EditID"].ToString());
                    lastExistModel = (from r in context.StorePickAccount
                                      orderby r.StockPickAccountID descending
                                      where r.WHCode == whCode && r.CargoCode == cargoCode && r.StockPickAccountID != storePickAccountID
                                      select r).FirstOrDefault();
                }

                if (lastExistModel == null)
                {
                    tbxAccountNumberOld.Text   = "0";
                    tbxFactCheckNumberOld.Text = "0";
                    tbxIsProfitOrLostOld.Text  = "0";
                }
                else
                {
                    tbxAccountNumberOld.Text   = lastExistModel.AccountNumber.ToString();
                    tbxFactCheckNumberOld.Text = lastExistModel.FactCheckNumber.ToString();
                    tbxIsProfitOrLostOld.Text  = lastExistModel.IsProfitOrLoss.ToString();
                }
            }
        }
예제 #8
0
        /// <summary>
        /// 行命令触发前先清空界面消息提示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gv_BinList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridView senderGrid = sender as GridView;

            //更新或删除前对消息Label清空
            if (e.CommandName == "Edit" || e.CommandName == "Update" || e.CommandName == "Delete")
            {
                //lblGridViewMsg.Text = "";
                ClearTipMsgLabel();//清除提示信息
            }
            else if (e.CommandName == "MyDefineUpdate")
            {
                lblGridViewMsg.Text = "";
                if (senderGrid.EditIndex != -1)
                {
                    int editBinCode = (int)senderGrid.DataKeys[senderGrid.EditIndex].Value;
                    try
                    {
                        using (GoldEntities context = new GoldEntities())
                        {
                            PackageStatistic updateModel = (from r in context.PackageStatistic where r.PSID == editBinCode select r).FirstOrDefault();
                            string           msg         = "";
                            if (GetUpdateModel(ref updateModel, senderGrid.Rows[senderGrid.EditIndex], out msg) == false)
                            {
                                lblGridViewMsg.Text = msg;
                                DAL.CommonConvert.ShowMessageBox(this.Page, msg);
                                return;
                            }
                            else
                            {
                                int result = context.SaveChanges();
                                if (result > 0)
                                {
                                    lblGridViewMsg.Text = "更新成功!";
                                    DAL.CommonConvert.ShowMessageBox(this.Page, "更新成功!");
                                    senderGrid.EditIndex = -1;//取消编辑状态
                                }
                                else
                                {
                                    DAL.CommonConvert.ShowMessageBox(this.Page, "更新失败(影响行数为0)!");
                                    lblGridViewMsg.Text = "更新失败(影响行数为0)";
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        DAL.CommonConvert.ShowMessageBox(this.Page, "更新失败!");
                        lblGridViewMsg.Text = "更新失败[" + Utility.LogHelper.GetExceptionMsg(ex) + "]";
                    }
                }
            }
        }
예제 #9
0
 /// <summary>
 /// 加载dropdownlist数据
 /// </summary>
 void LoadNewPanelDropDownList()
 {
     using (GoldEntities context = new GoldEntities())
     {
         //绑定仓库
         var result = (from r in context.WareHouse select new { r.WHCode, r.WHName }).OrderBy(r => r.WHCode).ToList();
         drpWHCode.Items.Clear();
         drpWHCode.DataTextField  = "WHName";
         drpWHCode.DataValueField = "WHCode";
         drpWHCode.DataSource     = result;
         drpWHCode.DataBind();
         drpWHCode.Items.Insert(0, new ListItem("", ""));
     }
 }
예제 #10
0
        /// <summary>
        /// 获取新增界面中的数据
        /// </summary>
        /// <param name="msg">异常消息</param>
        /// <returns></returns>
        private bool GetNewModel(out WareHouse newModel, out string msg)
        {
            msg      = "";
            newModel = null;
            try
            {
                newModel = new WareHouse();
                string whCode    = tbxWHCode.Text.Trim();
                string whName    = tbxWHName.Text.Trim();
                int    whType    = 0;
                bool   whEnabled = false;


                newModel.WHCode = whCode;
                newModel.WHName = whName;
                int.TryParse(DropDownList_WHType.SelectedItem.Value.ToString(), out whType);
                bool.TryParse(DropDownList_Enabled.SelectedItem.Value.ToString(), out whEnabled);
                newModel.WHType  = whType;
                newModel.Enabled = whEnabled;
                newModel.Address = tbxAddress.Text.Trim();
                newModel.Phone   = tbxPhone.Text.Trim();
                newModel.Comment = tbxComment.Text.Trim();

                using (GoldEntities context = new GoldEntities())
                {
                    var sameCode = (from r in context.WareHouse where r.WHCode == whCode select r).ToList();
                    if (sameCode != null && sameCode.Count > 0)
                    {
                        msg += "系统中已经存在编号为[" + whCode + "]的仓库信息,请重填编号";
                    }
                    var sameName = (from r in context.WareHouse where r.WHName == whName select r).ToList();
                    if (sameName != null && sameName.Count > 0)
                    {
                        msg += "系统中已经存在名称为[" + whName + "]的仓库信息,请重填名称";
                    }

                    if (msg.Length > 0)
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                msg = ex.Message.ToString();
                return(false);
            }
        }
예제 #11
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         lblSaveMsg.Text = "";
         string outMsg = "";
         if (ViewState["EditType"].ToString() == "1")//新增Insert
         {
             DAL.StorePickAccount newModel = new StorePickAccount();
             bool getNewOK = GetNewModel(out newModel, out outMsg);
             if (getNewOK == false)
             {
                 lblSaveMsg.Text = "新增失败![" + outMsg + "]";
                 return;
             }
             using (GoldEntities context = new GoldEntities())
             {
                 context.StorePickAccount.AddObject(newModel);
                 int AffectRowsCount = context.SaveChanges();
                 lblSaveMsg.Text  = "保存成功";
                 btnSave.Enabled  = false;
                 btnSave.CssClass = "ButtonImageStyleEnableFalse";
             }
         }
         else//更新Update
         {
             using (GoldEntities context = new GoldEntities())
             {
                 int EditID = int.Parse(ViewState["EditID"].ToString());
                 DAL.StorePickAccount updateModel = (from r in context.StorePickAccount where r.StockPickAccountID == EditID select r).FirstOrDefault();
                 bool getUpdateOK = GetUpdateModel(ref updateModel, out outMsg);
                 if (getUpdateOK == false)
                 {
                     lblSaveMsg.Text = "更新失败![" + outMsg + "]";
                     return;
                 }
                 //context.WareHouse.Attach(updateModel);
                 int AffectRowsCount = context.SaveChanges();
                 lblSaveMsg.Text  = "保存成功";
                 btnSave.Enabled  = false;
                 btnSave.CssClass = "ButtonImageStyleEnableFalse";
             }
         }
     }
     catch (Exception ex)
     {
         lblSaveMsg.Text = "更新失败![" + Utility.LogHelper.GetExceptionMsg(ex) + "]";
     }
 }
예제 #12
0
 private void LoadInfo(string ItemID)
 {
     using (GoldEntities context = new GoldEntities())
     {
         WareHouse existModel = (from r in context.WareHouse where r.WHCode == ItemID select r).FirstOrDefault();
         if (existModel != null)
         {
             tbxWHCode.Text = existModel.WHCode;
             tbxWHName.Text = existModel.WHName;
             DropDownList_WHType.SelectedIndex  = DropDownList_WHType.Items.IndexOf(DropDownList_WHType.Items.FindByValue(existModel.WHType.Value.ToString()));
             DropDownList_Enabled.SelectedIndex = DropDownList_Enabled.Items.IndexOf(DropDownList_Enabled.Items.FindByValue(existModel.Enabled.Value.ToString()));
             tbxAddress.Text = existModel.Address;
             tbxPhone.Text   = existModel.Phone;
             tbxComment.Text = existModel.Comment;
         }
     }
 }
예제 #13
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         lblSaveMsg.Text = "";
         string outMsg = "";
         if (ViewState["EditType"].ToString() == "1")//新增Insert
         {
             DAL.WareHouse newModel = new WareHouse();
             bool          getNewOK = GetNewModel(out newModel, out outMsg);
             if (getNewOK == false)
             {
                 lblSaveMsg.Text = "新增失败![" + outMsg + "]";
                 return;
             }
             using (GoldEntities context = new GoldEntities())
             {
                 context.WareHouse.AddObject(newModel);
                 int AffectRowsCount = context.SaveChanges();
                 lblSaveMsg.Text = "保存成功";
             }
         }
         else//更新Update
         {
             using (GoldEntities context = new GoldEntities())
             {
                 string        EditID      = ViewState["EditID"].ToString();
                 DAL.WareHouse updateModel = (from r in context.WareHouse where r.WHCode == EditID select r).FirstOrDefault();
                 bool          getUpdateOK = GetUpdateModel(ref updateModel, out outMsg);
                 if (getUpdateOK == false)
                 {
                     lblSaveMsg.Text = "更新失败![" + outMsg + "]";
                     return;
                 }
                 //context.WareHouse.Attach(updateModel);
                 int AffectRowsCount = context.SaveChanges();
                 lblSaveMsg.Text = "保存成功";
             }
         }
     }
     catch (Exception ex)
     {
         lblSaveMsg.Text = "更新失败![" + Utility.LogHelper.GetExceptionMsg(ex) + "]";
     }
 }
예제 #14
0
        protected void btnDelDept_Click(object sender, EventArgs e)
        {
            if (TreeView1.SelectedNode != null && string.IsNullOrEmpty(TreeView1.SelectedNode.Value) == false)
            {
                string msg = "";
                try
                {
                    string deptcode = lblCurrentDeptCode.Text;
                    string deptname = lblCurrentDeptName.Text;
                    if (deptcode == "root")
                    {
                        ShowMessageBox("顶级部门不可删除!");
                        return;
                    }
                    using (var edm = new GoldEntities())
                    {
                        Department query = (from p in edm.Department
                                            where p.DepartmentCode == deptcode
                                            select p).FirstOrDefault <Department>();
                        edm.Department.DeleteObject(query);
                        int affectRows = edm.SaveChanges();
                        msg = "部门[" + deptname + "]删除成功![影响行数" + affectRows.ToString() + "]";
                    }
                    ShowMessageBox(msg);

                    //删除成功后清除界面信息
                    lblCurrentDeptCode.Text = "";
                    lblCurrentDeptName.Text = "";
                    btnDelDept.Enabled      = false;
                    btnDelDept.CssClass     = "ButtonImageStyleEnableFalse";
                }
                catch (Exception ex)
                {
                    msg = "删除失败";
                    Utility.LogHelper.WriteLog(Utility.LogHelper.LogLevel.Error, "删除部门信息出错!", ex);
                    ShowMessageBox(msg, ex);
                }
                //重新加载TreeView
                InitTree();
            }
            else
            {
                ShowMessageBox("请先点击选中左侧的部门,然后再点击此删除按钮!");
            }
        }
예제 #15
0
        /// <summary>
        /// 多项删除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                ClearTipMsgLabel();//清除提示信息

                List <int> checkedDelList = GetCheckItemID();
                if (checkedDelList.Count <= 0)
                {
                    lblCheckMsg.Text = "请先选中待删除的项";
                    DAL.CommonConvert.ShowMessageBox(this.Page, "请先选中待删除的项!");
                    return;
                }

                using (GoldEntities context = new GoldEntities())
                {
                    foreach (int delCode in checkedDelList)
                    {
                        PackageStatistic delObject = (from r in context.PackageStatistic where r.PSID.Equals(delCode) select r).FirstOrDefault();

                        context.DeleteObject(delObject);
                    }
                    int delRow = context.SaveChanges();
                    if (delRow > 0)
                    {
                        DAL.CommonConvert.ShowMessageBox(this.Page, "删除成功![已删除" + delRow.ToString() + "项]");
                        lblCheckMsg.Text = "删除成功![已删除" + delRow.ToString() + "项]";
                    }
                    else
                    {
                        DAL.CommonConvert.ShowMessageBox(this.Page, "删除失败!");
                        lblCheckMsg.Text = "删除失败!";
                    }

                    //GridViewBind();//删除后重新绑定数据
                    gv_BinList.DataBind();
                }
            }
            catch (Exception ex)
            {
                DAL.CommonConvert.ShowMessageBox(this.Page, "删除失败!");
                lblGridViewMsg.Text = "删除失败[" + Utility.LogHelper.GetExceptionMsg(ex) + "]";
            }
        }
예제 #16
0
        private void CreatChildNodes(TreeNode node, Department department, GoldEntities edm)
        {
            var children = from temp in edm.Department
                           where temp.Parent == department.DepartmentCode &&
                           temp.DepartmentCode != "root"
                           select temp;

            if (children.Any())
            {
                foreach (Department child in children)
                {
                    TreeNode childNode = new TreeNode();
                    childNode.Text  = child.DepartmentName;
                    childNode.Value = child.DepartmentCode;
                    CreatChildNodes(childNode, child, edm);
                    node.ChildNodes.Add(childNode);
                }
            }
        }
예제 #17
0
        private void GridViewBind()
        {
            try
            {
                string deptCode = TreeView1.SelectedValue;
                using (GoldEntities context = new GoldEntities())
                {
                    var result = (from r in context.Users select r).ToList();
                    if (deptCode == "root")
                    {
                        deptCode = "";
                    }
                    if (!string.IsNullOrEmpty(deptCode))
                    {
                        result = (from r in result where r.DepartmentCode == deptCode select r).ToList();
                    }



                    string        sortExpression = GridView1.Attributes["sortExpression"];
                    SortDirection sortDirection  = GridView1.Attributes["sortDirection"] == "ASC" ? SortDirection.Ascending : SortDirection.Descending;

                    if (sortDirection == SortDirection.Ascending)
                    {
                        result = result.OrderBy(r => r.GetType().GetProperty(sortExpression).GetValue(r, null)).ToList();
                    }
                    else
                    {
                        result = result.OrderByDescending(r => r.GetType().GetProperty(sortExpression).GetValue(r, null)).ToList();
                    }


                    GridView1.DataSource = result;
                    GridView1.DataBind();
                }
            }
            catch (Exception ex)
            {
                string msg = Utility.LogHelper.GetExceptionMsg(ex).Replace("\r", "").Replace("\n", "");
                DAL.CommonConvert.ShowMessageBox(this.Page, "加载用户列表信息失败!详细信息:" + msg);
                Utility.LogHelper.WriteLog(Utility.LogHelper.LogLevel.Error, "加载用户列表信息失败!", ex);
            }
        }
예제 #18
0
        private void InitTree()
        {
            TreeView1.Nodes.Clear();

            using (var edm = new GoldEntities())
            {
                var root = (from d in edm.DataDict
                            where d.Category == "root"
                            select d).ToList();

                foreach (DataDict dict in root)
                {
                    TreeNode rootNode = new TreeNode();
                    rootNode.Text  = dict.Name + "(" + dict.Code + ")";
                    rootNode.Value = dict.Code;
                    TreeView1.Nodes.Add(rootNode);
                }
            }
        }
예제 #19
0
        private void InitTree()
        {
            TreeView1.Nodes.Clear();

            using (var edm = new GoldEntities())
            {
                var query = from p in edm.Department
                            where p.DepartmentCode == "root"
                            select p;

                Department root;
                if (query.Count <Department>() == 0)
                {
                    var tmp = edm.CreateObject <Department>();
                    tmp.DepartmentCode = "root";
                    tmp.DepartmentName = "深圳金币";
                    tmp.Parent         = "0";

                    edm.AddToDepartment(tmp);
                    edm.SaveChanges();

                    root = tmp;
                }
                else
                {
                    root = query.First();
                }

                TreeNode rootNode = new TreeNode();
                rootNode.Text  = root.DepartmentName;
                rootNode.Value = root.DepartmentCode;
                CreatChildNodes(rootNode, root, edm);
                TreeView1.Nodes.Add(rootNode);
                rootNode.ExpandAll();

                if (TreeView1.SelectedNode == null)
                {
                    rootNode.Select();
                    GridViewBind();//显示全部用户
                }
            }
        }
예제 #20
0
        /// <summary>
        /// 加载dropdownlist数据
        /// </summary>
        void LoadNewPanelDropDownList()
        {
            using (GoldEntities context = new GoldEntities())
            {
                //绑定存提状态
                List <NameValueModel> ListPickOrStore = Gold.Utility.EnumData.GetEnumsList(typeof(Gold.Utility.EnumData.PickOrStore));
                DropDownList_StorePickType.Items.Clear();
                DropDownList_StorePickType.DataTextField  = "Name";
                DropDownList_StorePickType.DataValueField = "Value";
                DropDownList_StorePickType.DataSource     = ListPickOrStore;
                DropDownList_StorePickType.DataBind();
                DropDownList_StorePickType.Items.Insert(0, new ListItem("", ""));

                //绑定盈亏状态
                List <NameValueModel> ListIsProfitOrLoss = Gold.Utility.EnumData.GetEnumsList(typeof(Gold.Utility.EnumData.IsProfitOrLoss));
                DropDownList_IsProfitOrLoss.Items.Clear();
                DropDownList_IsProfitOrLoss.DataTextField  = "Name";
                DropDownList_IsProfitOrLoss.DataValueField = "Value";
                DropDownList_IsProfitOrLoss.DataSource     = ListIsProfitOrLoss;
                DropDownList_IsProfitOrLoss.DataBind();
                DropDownList_IsProfitOrLoss.Items.Insert(0, new ListItem("", ""));

                //绑定包装
                var result = (from r in context.Packages select new { r.PackageId, r.PackageName }).OrderBy(r => r.PackageName).ToList();
                DropDownList_PackageName.Items.Clear();
                DropDownList_PackageName.DataTextField  = "PackageName";
                DropDownList_PackageName.DataValueField = "PackageId";
                DropDownList_PackageName.DataSource     = result;
                DropDownList_PackageName.DataBind();
                DropDownList_PackageName.Items.Insert(0, new ListItem("", ""));

                //绑定仓库
                var resultWH = (from r in context.WareHouse select new { r.WHCode, r.WHName }).OrderBy(r => r.WHCode).ToList();
                DropDownList_WHCode.Items.Clear();
                DropDownList_WHCode.DataTextField  = "WHName";
                DropDownList_WHCode.DataValueField = "WHCode";
                DropDownList_WHCode.DataSource     = resultWH;
                DropDownList_WHCode.DataBind();
                DropDownList_WHCode.Items.Insert(0, new ListItem("", ""));
            }
        }
예제 #21
0
        //设置生成入库单按钮的显示或隐藏
        protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label lblWHName = e.Row.FindControl("lblWHName") as Label;
                if (lblWHName != null)
                {
                    if (lblWHName.Text.Trim() != string.Empty)
                    {
                        string defaultWHCode = string.Empty;
                        string defaultWHName = string.Empty;
                        //从配置文件读取默认的仓库--地王26库
                        if (System.Configuration.ConfigurationManager.AppSettings.AllKeys.Contains("DefaultWHCode"))
                        {
                            defaultWHCode = System.Configuration.ConfigurationManager.AppSettings["DefaultWHCode"].ToString();
                        }
                        if (defaultWHCode == string.Empty)
                        {
                            defaultWHCode = "20101";
                        }

                        using (var edm = new GoldEntities())
                        {
                            var tmpName = edm.WareHouse.Where(o => o.WHCode == defaultWHCode).Select(o => o.WHName).Distinct().ToList();
                            if (tmpName != null && tmpName.Count > 0)
                            {
                                defaultWHName = tmpName[0];
                            }
                        }
                        if (lblWHName.Text.Trim() != defaultWHName)
                        {
                            btnGenStockOut.Visible = false;
                        }
                        else
                        {
                            btnGenStockOut.Visible = true;
                        }
                    }
                }
            }
        }
예제 #22
0
        /// <summary>
        /// 加载新增Panel中的dropdownlist数据
        /// </summary>
        void LoadNewPanelDropDownList()
        {
            using (GoldEntities context = new GoldEntities())
            {
                //绑定型号
                var allModelList = (from r in context.Models orderby r.ModelName select new { r.ModelId, r.ModelName }).ToList();
                DropDownList_CargoModel.Items.Clear();
                DropDownList_CargoModel.DataTextField  = "ModelName";
                DropDownList_CargoModel.DataValueField = "ModelID";
                DropDownList_CargoModel.DataSource     = allModelList;
                DropDownList_CargoModel.DataBind();
                DropDownList_CargoModel.Items.Insert(0, new ListItem("", ""));

                //绑定规格
                var allSpecList = (from r in context.Specifications orderby r.SpecName select new { r.SpecId, r.SpecName }).ToList();
                DropDownList_CargoSpec.Items.Clear();
                DropDownList_CargoSpec.DataTextField  = "SpecName";
                DropDownList_CargoSpec.DataValueField = "SpecId";
                DropDownList_CargoSpec.DataSource     = allSpecList;
                DropDownList_CargoSpec.DataBind();
                DropDownList_CargoSpec.Items.Insert(0, new ListItem("", ""));

                //绑定仓库
                var result = (from r in context.WareHouse select new { r.WHCode, r.WHName }).OrderBy(r => r.WHCode).ToList();
                DropDownList_WHCode.Items.Clear();
                DropDownList_WHCode.DataTextField  = "WHName";
                DropDownList_WHCode.DataValueField = "WHCode";
                DropDownList_WHCode.DataSource     = result;
                DropDownList_WHCode.DataBind();
                DropDownList_WHCode.Items.Insert(0, new ListItem("", ""));

                //绑定是否低于安全库存量状态
                List <NameValueModel> ListIsUnderSafeLine = Gold.Utility.EnumData.GetEnumsList(typeof(Gold.Utility.EnumData.IsUnderSafeLine));
                DropDownList_IsUnderSafe.Items.Clear();
                DropDownList_IsUnderSafe.DataTextField  = "Name";
                DropDownList_IsUnderSafe.DataValueField = "Value";
                DropDownList_IsUnderSafe.DataSource     = ListIsUnderSafeLine;
                DropDownList_IsUnderSafe.DataBind();
                DropDownList_IsUnderSafe.Items.Insert(0, new ListItem("", ""));
            }
        }
예제 #23
0
        protected void btnSaveValue_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtValueCode.Text.Trim()))
            {
                lblMessage2.Text = "代码不能为空!";
                return;
            }

            if (string.IsNullOrEmpty(txtValueName.Text.Trim()))
            {
                lblMessage2.Text = "名称不能为空!";
                return;
            }


            using (var edm = new GoldEntities())
            {
                var tmp = edm.CreateObject <DataDict>();
                tmp.Name = txtValueName.Text.Trim();
                tmp.Code = txtValueCode.Text.Trim();
                int x;
                if (!string.IsNullOrEmpty(txtValueOrder.Text.Trim()) &&
                    int.TryParse(txtValueOrder.Text.Trim(), out x))
                {
                    tmp.Order = x;
                }

                tmp.Category = TreeView1.SelectedNode.Value;
                tmp.Enabled  = true;

                edm.AddToDataDict(tmp);
                edm.SaveChanges();

                GridView1.DataBind();

                txtValueCode.Text  = "";
                txtValueName.Text  = "";
                txtValueOrder.Text = "";
                lblMessage2.Text   = "保存成功!";
            }
        }
예제 #24
0
        /// <summary>
        /// 加载新增Panel中的dropdownlist数据
        /// </summary>
        void LoadNewPanelDropDownList()
        {
            using (GoldEntities context = new GoldEntities())
            {
                //绑定包装  查询
                var result = (from r in context.Packages select new { r.PackageId, r.PackageName }).OrderBy(r => r.PackageName).ToList();
                DropDownList_PackageName.Items.Clear();
                DropDownList_PackageName.DataTextField  = "PackageName";
                DropDownList_PackageName.DataValueField = "PackageId";
                DropDownList_PackageName.DataSource     = result;
                DropDownList_PackageName.DataBind();
                DropDownList_PackageName.Items.Insert(0, new ListItem("", ""));

                //绑定包装  新增
                DropDownListNewPackage.Items.Clear();
                DropDownListNewPackage.DataTextField  = "PackageName";
                DropDownListNewPackage.DataValueField = "PackageId";
                DropDownListNewPackage.DataSource     = result;
                DropDownListNewPackage.DataBind();
                DropDownListNewPackage.Items.Insert(0, new ListItem("", ""));

                //绑定仓库 查询
                var resultWH = (from r in context.WareHouse select new { r.WHCode, r.WHName }).OrderBy(r => r.WHCode).ToList();
                DropDownList_WHCode.Items.Clear();
                DropDownList_WHCode.DataTextField  = "WHName";
                DropDownList_WHCode.DataValueField = "WHCode";
                DropDownList_WHCode.DataSource     = resultWH;
                DropDownList_WHCode.DataBind();
                DropDownList_WHCode.Items.Insert(0, new ListItem("", ""));

                //绑定仓库 新增
                DropDownListNewWHCode.Items.Clear();
                DropDownListNewWHCode.DataTextField  = "WHName";
                DropDownListNewWHCode.DataValueField = "WHCode";
                DropDownListNewWHCode.DataSource     = resultWH;
                DropDownListNewWHCode.DataBind();
                DropDownListNewWHCode.Items.Insert(0, new ListItem("", ""));
            }
        }