示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //1.验证用户权限
            if (!this.Master.A_Edit)
            {
                Response.Write("你没有权限访问此功能!");
                Response.End();
                return;
            }
            //2.取得用户变量
            string departmentId = this.ddlDepartment.SelectedItem.Value;
            string userId       = this.hidden_ddlUser.Value;
            string inputDate    = this.txtInputDate.Text.Trim();
            string productId    = this.txtProductID.Text.Trim();
            string price        = this.txtPrice.Text.Trim();
            string unit         = this.txtUnit.Text.Trim();
            string quantity     = this.txtQuantity.Text.Trim();
            string remark       = this.txtRemark.Text.Trim();

            //3.验证用户变量,包含Request.QueryString及Request.Form
            //4.业务处理过程
            Equipment.MODEL equipmentModel = Equipment.NewDataModel();
            equipmentModel.DepartmentID.value = departmentId;
            equipmentModel.UserID.value       = userId;
            equipmentModel.AddDate.value      = inputDate;
            equipmentModel.ProductID.value    = productId;
            equipmentModel.Price.value        = price;
            equipmentModel.Unit.value         = unit;
            equipmentModel.Quantity.value     = quantity;
            equipmentModel.Remark.value       = remark;
            //填写主要业务逻辑代码

            int row = equipmentModel.Save();

            //5.(用户及业务对象)统计与状态

            if (row > 0)
            {
                XSql.Execute("EXEC Assets_AddConsuming " + this.PID.Value + "," + this.txtQuantity.Text + ",'" + this.txtProductID.Text + "'");
                //6.登记日志
                WX.Main.AddLog(LogType.Default, "个人装备录入成功!", null);
                //7.返回处理结果或返回其它页面。
                ULCode.Debug.Alert("个人装备录入成功!", "Ass_EquipmentList.aspx");
            }
            else
            {
                ULCode.Debug.Alert("个人装备录入失败!", "Ass_EquipmentList.aspx");
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string type         = "领用";
            string opUserID     = this.txtOpUserID.Value;
            string opTime       = this.txtOpTime.Text.Trim();
            string opIP         = Request.UserHostAddress;
            string userId       = this.hidden_ddlUser.Value;
            string departmentId = this.ddlDepartment.SelectedItem.Value;
            //string deadline = this.txtDeadline.Text.Trim();
            string maturityDate = this.hidden_MaturityDate.Value;
            string quantity     = this.txtQuantity.Text.Trim();
            string productID    = this.txtProductID.Text.Trim();
            string content      = this.txtRemarks.Text.Trim();
            string unit         = this.txtUnit.Text.Trim();
            string price        = this.txtPrice.Text.Trim();

            WX.Ass.Log.MODEL logModel = WX.Ass.Log.NewDataModel();
            logModel.Type.value         = type;
            logModel.OpUserID.value     = opUserID;
            logModel.OpTime.value       = opTime;
            logModel.OpIP.value         = opIP;
            logModel.UserID.value       = userId;
            logModel.DepartmentID.value = departmentId;
            //logModel.Deadline.value = deadline;
            if (string.IsNullOrEmpty(maturityDate))
            {
                logModel.MaturityDate.set(DBNull.Value);
            }
            else
            {
                logModel.MaturityDate.value = maturityDate;
            }
            logModel.Quantity.value  = quantity;
            logModel.ProductID.value = productID;
            logModel.Content.value   = content;
            logModel.Unit.value      = unit;
            logModel.Price.value     = price;
            int singleRow = logModel.Save();
            int row       = 0;

            if (singleRow > 0)
            {
                if (this.PID.Value != "0")
                {
                    XSql.Execute("EXEC Assets_AddConsuming " + this.PID.Value + "," + this.txtQuantity.Text + ",'" + this.txtProductID.Text + "'");
                    Equipment.MODEL equipmentModel = Equipment.NewDataModel();
                    equipmentModel.DepartmentID.value = departmentId;
                    equipmentModel.UserID.value       = userId;
                    equipmentModel.ProductID.value    = productID;
                    equipmentModel.Quantity.value     = quantity;
                    equipmentModel.AddDate.value      = opTime;
                    equipmentModel.Price.value        = price;
                    equipmentModel.Unit.value         = unit;
                    equipmentModel.Remark.value       = content;
                    equipmentModel.Save();
                    if (row > 0)
                    {
                        WX.Main.AddLog(WX.LogType.Default, "产品领用添加成功!", null);
                    }
                }
            }
            if (singleRow > 0)
            {
                ULCode.Debug.Confirm("产品领用添加成功!", "Ass_AddConsuming.aspx", "Ass_AssetsList.aspx");
            }
            else
            {
                ULCode.Debug.Alert("产品领用添加失败!", "Ass_AddConsuming.aspx");
            }
        }