Пример #1
0
 protected void txtSubmit_Click(object sender, EventArgs e)
 {
     using (ISession session = new Session())
     {
         Magic.Sys.User user = Magic.Sys.User.Retrieve(session, this.UserId);
         if (user == null)
         {
             WebUtil.ShowError(this, "请重新登陆");
             return;
         }
         if (this.txtOldPwd.Value != user.Password)
         {
             WebUtil.ShowError(this, "原密码不正确");
             return;
         }
         if (this.txtNewPwd.Value != this.txtNewPwd2.Value)
         {
             WebUtil.ShowError(this, "2次输入的密码不正确");
             return;
         }
         user.Password = this.txtNewPwd.Value;
         user.Update(session, "Password");
         WebUtil.ShowMsg(this, "密码修改成功");
     }
 }
Пример #2
0
    private void SetView(ISession session, INVCheckHead head)
    {
        if (!this.IsNew)
        {
            WebUtil.DisableControl(this.drpLocation);
        }
        if (head != null)
        {
            if (!string.IsNullOrEmpty(head.LocationCode) && head.LocationCode.Trim().Length > 0)
            {
                WHLocation location = WHLocation.Retrieve(session, head.LocationCode);
                this.drpLocation.Items.Clear();
                this.drpLocation.Items.Add(new ListItem(location.Name, location.LocationCode));
            }
            this.drpCheckType.SelectedValue = head.CheckType.ToString();
            this.txtMemo.Text = head.Note;
            OrderStatusDef statusDef = OrderStatusDef.Retrieve(session, INVCheckHead.ORDER_TYPE_CHK, (int)head.Status);
            if (statusDef != null)
            {
                this.lblStatus.Text = statusDef.StatusText;
            }
            Magic.Sys.User user = null;
            if (head.CreateUser > 0)
            {
                user = Magic.Sys.User.Retrieve(session, head.CreateUser);
                if (user != null)
                {
                    this.lblUser.Text = user.FullName;
                }
            }
            this.lblCreateTime.Text    = RenderUtil.FormatDatetime(head.CreateTime);
            this.lblApproveResult.Text = ERPUtil.EnumText <ApproveStatus>(head.ApproveResult);
            if (head.ApproveUser > 0)
            {
                user = Magic.Sys.User.Retrieve(session, head.ApproveUser);
                if (user != null)
                {
                    this.lblApproveUser.Text = user.FullName;
                }
            }
            this.lblApproveTime.Text = RenderUtil.FormatDatetime(head.ApproveTime);
            this.txtApproveNote.Text = head.ApproveNote;

            if (head.Status != INVCheckStatus.New)
            {
                WebUtil.DisableControl(this.txtMemo);
                WebUtil.DisableControl(this.drpCheckType);
                this.cmdSave.Visible = false;
            }
        }
    }
Пример #3
0
 protected void MagicItemCommand(object sender, MagicItemEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         //MagicToolBar的事件
         bool deleted = false;
         using (ISession session = new Session())
         {
             session.BeginTransaction();
             try
             {
                 foreach (RepeaterItem item in this.rptUser.Items)
                 {
                     HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                     if (chk != null && chk.Checked && Cast.Int(chk.Value) > 0)
                     {
                         Magic.Sys.User user = Magic.Sys.User.Retrieve(session, Cast.Int(chk.Value));
                         if (user != null)
                         {
                             //逻辑删除,仅将状态update成UserStatus.Deleted
                             user.Status     = UserStatus.Deleted;
                             user.ModifyBy   = Magic.Security.SecuritySession.CurrentUser.UserId;
                             user.ModifyTime = DateTime.Now;
                             //Update方法有2个版本,
                             //1. 只传ISession参数,将更新实体的所有属性
                             //2. 传一个属性名称的字符串数组,只更新指定的字段
                             user.Update(session, "Status", "ModifyBy", "ModifyTime");
                             deleted = true;
                         }
                     }
                 }
                 session.Commit();
                 if (deleted)
                 {
                     this.QueryAndBindData(session, this.magicPagerMain.CurrentPageIndex, this.magicPagerMain.PageSize, true);
                 }
                 WebUtil.ShowMsg(this, "选择的用户已经被删除", "操作成功");
             }
             catch (Exception err)
             {
                 session.Rollback();
                 WebUtil.ShowError(this, err);
             }
         }
     }
 }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Magic.Sys.User user = null;
     using (ISession session = new Session())
     {
         user = Magic.Sys.User.Retrieve(session, this.UserId);
     }
     if (user != null)
     {
         this.txtUserName.Value   = user.UserName;
         this.txtFullName.Value   = user.FullName;
         this.txtLoginTime.Value  = RenderUtil.FormatDatetime(user.LastLogonTime);
         this.txtCreateTime.Value = RenderUtil.FormatDatetime(user.CreateTime);
     }
     else
     {
         WebUtil.ShowMsg(this, "请重新登陆");
     }
 }
Пример #5
0
        public static SimpleJson SaveOrg(ISession session, Org org, OrgType type, string action, User oper)
        {
            Org original = null;
            switch (action)
            {
                case "create":
                    Org parent = Org.Get(session, type, org.ParentId);
                    if (parent == null) return new SimpleJson().HandleError(string.Format("父节点{0}不存在", org.ParentId));

                    org.CreateBy = oper.UserId;
                    org.CreateDate = DateTime.Now;
                    org.IsVirtual = false;
                    org.IsRoot = false;
                    org.OrgType = type;
                    org.Deleted = false;
                    org.OrgSeq = org.OrgSeq <= 0 ? (short)(Org.MaxSeq(session, org.ParentId) + 1) : org.OrgSeq;
                    org.Create(session);

                    if (OrgTypeRegistry.HasExtAttr(type) && org.ExtAttr != null)
                    {
                        IOrgExtend oext = org.ExtAttr as IOrgExtend;
                        oext.OrgId = org.OrgId;
                        oext.Create(session);
                    }

                    parent.AddChild(org);
                    Org.SortOrg(parent, org);
                    return Org.GetOrgJSON(session, org);
                case "update":
                    original = Org.Get(session, type, org.OrgId);
                    if (original == null) return new SimpleJson().HandleError(string.Format("{0}不存在", org.OrgId));
                    original.OrgCode = org.OrgCode;
                    original.OrgName = org.OrgName;
                    original.Description = org.Description;
                    original.ModifyBy = oper.UserId;
                    original.ModifyDate = DateTime.Now;
                    original.OrgSeq = org.OrgSeq;
                    original.Manager = org.Manager;
                    original.Update(session, "OrgCode", "OrgName", "Description", "ModifyBy", "ModifyDate", "OrgSeq", "Manager");

                    if (OrgTypeRegistry.HasExtAttr(type) && org.ExtAttr != null)
                    {
                        IOrgExtend oext = org.ExtAttr as IOrgExtend;
                        oext.OrgId = org.OrgId;
                        oext.Update(session);
                        original.ExtAttr = oext;
                    }

                    Org.SortOrg(Org.Get(session, type, original.ParentId), original);
                    return Org.GetOrgJSON(session, original);
                default:
                    return new SimpleJson().HandleError(string.Format("无效的操作{0}", action));
            }
        }
Пример #6
0
        /// <summary>
        ///  Map a DataRow to a User Entity.
        /// </summary>
        /// <returns></returns>
        public static User Row2Entity(System.Data.DataRow row)
        {
            if (row == null) return null;

            User entity = new User();

            if (!row.IsNull("USR_ID"))
                entity._userId = (int)(row["USR_ID"]);
            if (!row.IsNull("USR_LOGIN_ID"))
                entity._userName = (string)(row["USR_LOGIN_ID"]);
            if (!row.IsNull("USR_PSW"))
                entity._password = (string)(row["USR_PSW"]);
            if (!row.IsNull("USR_NAME"))
                entity._fullName = (string)(row["USR_NAME"]);
            if (!row.IsNull("USR_TYPE"))
                entity._userType =(OrgType)Enum.Parse(typeof(OrgType),(row["USR_TYPE"]).ToString());
            if (!row.IsNull("USR_EMAIL"))
                entity._email = (string)(row["USR_EMAIL"]);
            if (!row.IsNull("USR_GENDER"))
                entity._gender = (bool)(row["USR_GENDER"]);
            if (!row.IsNull("USR_WORK_NUM"))
                entity._employeeNo = (string)(row["USR_WORK_NUM"]);
            if (!row.IsNull("USR_EXT"))
                entity._ext = (string)(row["USR_EXT"]);
            if (!row.IsNull("USR_MOBILE"))
                entity._mobile = (string)(row["USR_MOBILE"]);
            if (!row.IsNull("USR_HOME_PHONE"))
                entity._homePhone = (string)(row["USR_HOME_PHONE"]);
            if (!row.IsNull("USR_HOME_ADDR"))
                entity._homeAddress = (string)(row["USR_HOME_ADDR"]);
            if (!row.IsNull("USR_BIRTHDAY"))
                entity._birthday = (DateTime)(row["USR_BIRTHDAY"]);
            if (!row.IsNull("USR_NOTE"))
                entity._note = (string)(row["USR_NOTE"]);
            if (!row.IsNull("USR_STATUS"))
                entity._status = (UserStatus)Enum.Parse(typeof(UserStatus),(row["USR_STATUS"]).ToString());
            if (!row.IsNull("ORG_ID"))
                entity._orgId = (int)(row["ORG_ID"]);
            if (!row.IsNull("LAST_LOGIN"))
                entity._lastLogonTime = (DateTime)(row["LAST_LOGIN"]);
            if (!row.IsNull("CREATE_TIME"))
                entity._createTime = (DateTime)(row["CREATE_TIME"]);
            if (!row.IsNull("CREATE_BY"))
                entity._createBy = (int)(row["CREATE_BY"]);
            if (!row.IsNull("MODIFY_BY"))
                entity._modifyBy = (int)(row["MODIFY_BY"]);
            if (!row.IsNull("MODIFY_TIME"))
                entity._modifyTime = (DateTime)(row["MODIFY_TIME"]);

            return entity;
        }
Пример #7
0
 public static bool Delete(ISession session, User user)
 {
     //删除用户,需要删除该用户的所有关联,包括:
     // 用户组,用户权限
     user.Status = UserStatus.Deleted;
     return EntityManager.Update(session, user);
     //return EntityManager.Delete(session, user);
 }
Пример #8
0
    protected void MagicItemCommand(object sender, MagicItemEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            #region  除
            using (ISession session = new Session())
            {
                try
                {
                    session.BeginTransaction();
                    foreach (RepeaterItem item in this.repeatControl.Items)
                    {
                        HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
                        if (chk.Checked)
                        {
                            ICLine line = ICLine.Retrieve(session, this.OrderNumber, chk.Value.Trim());
                            if (line != null)
                            {
                                line.Delete(session);
                            }
                        }
                    }
                    session.Commit();
                    this.QueryAndBindData(session, null);
                    WebUtil.ShowMsg(this, "选择的明细已经删除");
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Release")
        {
            #region 发布
            using (ISession session = new Session())
            {
                try
                {
                    session.BeginTransaction();
                    ICHead head = ICHead.Retrieve(session, this.OrderNumber);
                    head.Release(session);
                    session.Commit();
                    WebUtil.ShowMsg(this, "发布成功");
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Close")
        {
            #region 关闭
            using (ISession session = new Session())
            {
                try
                {
                    ICHead head = ICHead.Retrieve(session, this.OrderNumber);
                    if (head == null)
                    {
                        return;
                    }
                    session.BeginTransaction();
                    head.Close(session);
                    session.Commit();
                    WebUtil.ShowMsg(this, "交接单" + head.OrderNumber + "已经完成");
                    this.QueryAndBindData(session, head);
                    this.SetView(head);
                }
                catch (Exception er)
                {
                    session.Rollback();
                    WebUtil.ShowError(this, er);
                }
            }
            #endregion
        }
        else if (e.CommandName == "Download")
        {
            #region  载
            DataSet ds = null;
            IDictionary <string, string> dic = new Dictionary <string, string>();
            #region 初始化dic
            dic["$LogisName$"]    = "";
            dic["$LogisAddress$"] = "";
            dic["$LogisContact$"] = "";
            dic["$LogisPhone$"]   = "";
            dic["$LogisZipCode$"] = "";
            dic["$LogisFax$"]     = "";
            dic["$ICNumber$"]     = "";
            dic["$ICUser$"]       = "";
            dic["$AgentAmt$"]     = "";
            dic["$Note$"]         = "";
            dic["$Status$"]       = "";
            dic["$ICTime$"]       = "";
            dic["$ICBoxCount$"]   = "";
            #endregion
            IList <DownloadFormat> format = new List <DownloadFormat>()
            {
                new DownloadFormat(DataType.NumberText, "", "OrderNumber"),
                new DownloadFormat(DataType.NumberText, "", "ShippingNumber"),
                new DownloadFormat(DataType.NumberText, "", "SaleOrderNumber"),
                new DownloadFormat(DataType.NumberText, "", "InvoiceNumber"),
                new DownloadFormat(DataType.Number, "", "PackageWeight"),
                new DownloadFormat(DataType.Number, "", "PackageCount"),
                new DownloadFormat(DataType.Text, "", "Contact"),
                new DownloadFormat(DataType.Text, "", "Province", "City"), //省市2区县待完善
                new DownloadFormat(DataType.NumberText, "", "PostCode"),
                new DownloadFormat(DataType.Text, "", "Address"),
                new DownloadFormat(DataType.NumberText, "", "Phone"),
                new DownloadFormat(DataType.NumberText, "", "Mobile"),
                new DownloadFormat(DataType.Number, "", "AgentAmt"),
                new DownloadFormat(DataType.Text, "", "Remark")
            };
            using (ISession session = new Session())
            {
                ds = session.CreateObjectQuery(@"
SELECT 
    A.OrderNumber AS OrderNumber,A.ShippingNumber as ShippingNumber,A.SaleOrderNumber AS SaleOrderNumber
    ,A.InvoiceNumber as InvoiceNumber,A.PackageWeight as PackageWeight,A.PackageCount as PackageCount
    ,A.Contact as Contact,A.Province as Province,A.City as City,A.Address as Address,A.Mobile as Mobile,A.Phone as Phone
    ,A.AgentAmt as AgentAmt,A.Remark as Remark,A.PostCode as PostCode
FROM ICLine L
inner JOIN CRMSN A ON L.RefOrderNumber=A.OrderNumber
LEFT JOIN Member E ON A.MemberID= E.MemberID
order by L.LineNumber")
                     .Attach(typeof(Magic.ERP.Orders.ICLine))
                     .Attach(typeof(Magic.ERP.Orders.CRMSN))
                     .Attach(typeof(Magic.Basis.Member))
                     .And(Magic.Framework.ORM.Query.Exp.Eq("L.OrderNumber", this.OrderNumber))
                     .DataSet();

                decimal totalAmt = 0M;
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    totalAmt += Cast.Decimal("AgentAmt");
                }

                ICHead head = ICHead.Retrieve(session, this.OrderNumber);
                if (head == null)
                {
                    WebUtil.ShowError(this, "交接单" + this.OrderNumber + "不存在");
                    return;
                }
                dic["$ICNumber$"]   = "'" + head.OrderNumber;
                dic["$AgentAmt$"]   = totalAmt.ToString("#0.#0");
                dic["$Note$"]       = "'" + head.Note;
                dic["$Status$"]     = ERPUtil.StatusText(session, CRMSN.ORDER_TYPE_CODE_SD, head.Status);
                dic["$ICTime$"]     = "'" + head.CreateTime.ToString("yyyy-MM-dd");
                dic["$ICBoxCount$"] = "'" + head.TotalPackageCount(session).ToString();
                Logistics logis = Logistics.Retrieve(session, head.LogisticCompID);
                if (logis != null)
                {
                    dic["$LogisName$"]    = logis.ShortName;
                    dic["$LogisAddress$"] = logis.Address;
                    dic["$LogisContact$"] = logis.Contact;
                    dic["$LogisPhone$"]   = "'" + logis.Phone;
                    dic["$LogisZipCode$"] = "'" + logis.ZipCode;
                    dic["$LogisFax$"]     = "'" + logis.Fax;
                }
                if (head.CreateUser > 0)
                {
                    Magic.Sys.User user = Magic.Sys.User.Retrieve(session, head.CreateUser);
                    if (user != null)
                    {
                        dic["$ICUser$"] = user.FullName;
                    }
                }
            }
            if (ds == null)
            {
                WebUtil.ShowError(this, "没有数据下载或者下载出错了");
                return;
            }

            string fileName = DownloadUtil.DownloadXls("IC_" + this.OrderNumber + ".xls", "IC", Server.MapPath("/Template/IC_Download.xls"), dic, 7, format, ds);
            this.frameDownload.Attributes["src"] = fileName;
            #endregion
        }
    }