Esempio n. 1
0
 protected void btnSave_Click(object sender, System.EventArgs e)
 {
     using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString))
     {
         sqlConnection.Open();
         SqlTransaction sqlTransaction = sqlConnection.BeginTransaction();
         try
         {
             foreach (GridViewRow gridViewRow in this.gvwContractType.Rows)
             {
                 ContractTypeModel contractTypeModel = new ContractTypeModel();
                 string            typeID            = this.gvwContractType.DataKeys[gridViewRow.RowIndex].Value.ToString();
                 DropDownList      dropDownList      = (DropDownList)gridViewRow.FindControl("ddlCBS");
                 contractTypeModel.TypeID = typeID;
                 if (!string.IsNullOrEmpty(dropDownList.SelectedValue.Trim()))
                 {
                     contractTypeModel.CBSCode = dropDownList.SelectedValue.Trim();
                 }
                 else
                 {
                     contractTypeModel.CBSCode = null;
                 }
                 this.contractType.UpdateCBSCode(sqlTransaction, contractTypeModel);
             }
             sqlTransaction.Commit();
             base.RegisterScript("alert('系统提示:\\n修改成功!');");
         }
         catch
         {
             base.RegisterScript("alert('系统提示:\\n修改失败!');");
         }
     }
 }
Esempio n. 2
0
        public void Add(SqlTransaction trans, ContractTypeModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into Con_ContractType(");
            builder.Append("TypeID,TypeCode,TypeName,UserCodes,Notes,InputPerson,InputDate,CBSCode,TypeShort)");
            builder.Append(" values (");
            builder.Append("@TypeID,@TypeCode,@TypeName,@UserCodes,@Notes,@InputPerson,@InputDate,@CBSCode,@TypeShort)");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@TypeID", SqlDbType.NVarChar, 0x40), new SqlParameter("@TypeCode", SqlDbType.NVarChar, 0x40), new SqlParameter("@TypeName", SqlDbType.NVarChar, 0x80), new SqlParameter("@UserCodes", SqlDbType.NVarChar), new SqlParameter("@Notes", SqlDbType.NVarChar), new SqlParameter("@InputPerson", SqlDbType.NVarChar, 0x40), new SqlParameter("@InputDate", SqlDbType.DateTime), new SqlParameter("@CBSCode", SqlDbType.NVarChar, 200), new SqlParameter("@TypeShort", SqlDbType.NVarChar, 100) };
            commandParameters[0].Value = model.TypeID;
            commandParameters[1].Value = model.TypeCode;
            commandParameters[2].Value = model.TypeName;
            commandParameters[3].Value = model.UserCodes;
            commandParameters[4].Value = model.Notes;
            commandParameters[5].Value = model.InputPerson;
            commandParameters[6].Value = model.InputDate;
            if (string.IsNullOrEmpty(model.CBSCode))
            {
                commandParameters[7].Value = DBNull.Value;
            }
            else
            {
                commandParameters[7].Value = model.CBSCode;
            }
            commandParameters[8].Value = model.TypeShort;
            if (trans == null)
            {
                SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters);
            }
            else
            {
                SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters);
            }
        }
Esempio n. 3
0
        private ContractTypeModel GetModel(IDataReader dr)
        {
            ContractTypeModel model = new ContractTypeModel {
                TypeID      = DBHelper.GetString(dr["TypeID"]),
                TypeCode    = DBHelper.GetString(dr["TypeCode"]),
                TypeName    = DBHelper.GetString(dr["TypeName"]),
                UserCodes   = DBHelper.GetString(dr["UserCodes"]),
                Notes       = DBHelper.GetString(dr["Notes"]),
                InputPerson = DBHelper.GetString(dr["InputPerson"]),
                InputDate   = new DateTime?(DBHelper.GetDateTime(dr["InputDate"])),
                CBSCode     = DBHelper.GetString(dr["CBSCode"]),
                TypeShort   = DBHelper.GetString(dr["TypeShort"])
            };

            if (dr["IsValid"] != null)
            {
                if (dr["IsValid"].ToString() == "False")
                {
                    model.IsValid = "无效";
                    return(model);
                }
                model.IsValid = "有效";
                return(model);
            }
            model.IsValid = "有效";
            return(model);
        }
Esempio n. 4
0
        public virtual IActionResult Create(ContractTypeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContractType))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var item = model.ToEntity <ContractType>();

                //ensure we have "/" at the end


                _contractTypeService.InsertContractType(item);

                //activity log
                _customerActivityService.InsertActivity("AddNewContractType",
                                                        string.Format(_localizationService.GetResource("ActivityLog.AddNewContractType"), item.Id), item);

                SuccessNotification(_localizationService.GetResource("AppWork.Contracts.ContractType.Added"));

                return(continueEditing ? RedirectToAction("Edit", new { id = item.Id }) : RedirectToAction("List"));
            }

            //prepare model
            model = _contractModelFactory.PrepareContractTypeModel(model, null);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 5
0
        public void Update(ContractTypeModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update Con_ContractType set ");
            builder.Append("TypeCode=@TypeCode,");
            builder.Append("TypeName=@TypeName,");
            builder.Append("UserCodes=@UserCodes,");
            builder.Append("Notes=@Notes,");
            builder.Append("InputPerson=@InputPerson,");
            builder.Append("InputDate=@InputDate,");
            builder.Append("CBSCode=@CBSCode,");
            builder.Append("TypeShort=@TypeShort");
            builder.Append(" where TypeID=@TypeID ");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@TypeID", SqlDbType.NVarChar, 0x40), new SqlParameter("@TypeCode", SqlDbType.NVarChar, 0x40), new SqlParameter("@TypeName", SqlDbType.NVarChar, 0x80), new SqlParameter("@UserCodes", SqlDbType.NVarChar), new SqlParameter("@Notes", SqlDbType.NVarChar), new SqlParameter("@InputPerson", SqlDbType.NVarChar, 0x40), new SqlParameter("@InputDate", SqlDbType.DateTime), new SqlParameter("@CBSCode", SqlDbType.NVarChar, 200), new SqlParameter("@TypeShort", SqlDbType.NVarChar, 100) };
            commandParameters[0].Value = model.TypeID;
            commandParameters[1].Value = model.TypeCode;
            commandParameters[2].Value = model.TypeName;
            commandParameters[3].Value = model.UserCodes;
            commandParameters[4].Value = model.Notes;
            commandParameters[5].Value = model.InputPerson;
            commandParameters[6].Value = model.InputDate;
            if (!string.IsNullOrEmpty(model.CBSCode))
            {
                commandParameters[7].Value = model.CBSCode;
            }
            else
            {
                commandParameters[7].Value = DBNull.Value;
            }
            commandParameters[8].Value = model.TypeShort;
            SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters);
        }
Esempio n. 6
0
        public virtual IActionResult _Create(ContractTypeModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContractType))
            {
                return(AccessDeniedView());
            }

            if (ModelState.IsValid)
            {
                var item = model.ToEntity <ContractType>();

                //ensure we have "/" at the end


                _contractTypeService.InsertContractType(item);

                //activity log
                _customerActivityService.InsertActivity("AddNewContractType",
                                                        string.Format(_localizationService.GetResource("ActivityLog.AddNewContractType"), item.Id), item);
                return(JsonSuccessMessage(_localizationService.GetResource("AppWork.Contracts.ContractType.Added"), item.ToModel <ContractTypeModel>()));
            }

            //prepare model
            model = _contractModelFactory.PrepareContractTypeModel(model, null);

            //if we got this far, something failed, redisplay form
            return(JsonErrorMessage(_localizationService.GetResource("AppWork.Contracts.Contract.AddNewContractTypeError"), model));
        }
Esempio n. 7
0
        public async Task <ResponseModel> Delete(ContractTypeModel model)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                ContractType md = await _context.ContractTypeRepository.FirstOrDefaultAsync(m => m.Id == model.Id);

                if (!md.RowVersion.SequenceEqual(model.RowVersion))
                {
                    response.ResponseStatus = Core.CommonModel.Enums.ResponseStatus.OutOfDateData;
                    return(response);
                }

                md.Deleted    = true;
                md.UpdateBy   = base.UserId;
                md.UpdateDate = DateTime.Now;

                _context.ContractTypeRepository.Update(md);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Esempio n. 8
0
        public void UpdateCBSCode(SqlTransaction trans, ContractTypeModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update Con_ContractType set ");
            builder.Append("CBSCode=@CBSCode");
            builder.Append(" where TypeID=@TypeID ");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@TypeID", SqlDbType.NVarChar, 0x40), new SqlParameter("@CBSCode", SqlDbType.NVarChar, 200) };
            commandParameters[0].Value = model.TypeID;
            if (!string.IsNullOrEmpty(model.CBSCode))
            {
                commandParameters[1].Value = model.CBSCode;
            }
            else
            {
                commandParameters[1].Value = DBNull.Value;
            }
            if (trans != null)
            {
                SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters);
            }
            else
            {
                SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters);
            }
        }
Esempio n. 9
0
        private void btnContractTypeCode_Click(object sender, EventArgs e)
        {
            try
            {
                frmGenSelect frm = new frmGenSelect("Danh sách hợp đồng", "ContractType", "ID", "Name");
                frm.IsMultipleSelect = true;
                frm.ShowDialog();
                string temp = "";
                if (frm.getArrModel != null)
                {
                    for (int i = 0; i < frm.getArrModel.Length; i++)
                    {
                        ContractTypeModel _model = (ContractTypeModel)frm.getArrModel[i];

                        _ContractTypeIDs = _model.ID;
                        temp            += ((ContractTypeModel)_model).ID + ",";
                    }
                    txtTransactionCode.Text = temp.Substring(0, temp.Length - 1);
                    LoadData();
                }
            }

            catch (Exception ex)
            {
                frmGenMessageBox frm = new frmGenMessageBox("_SystemMessage", "frmGenSearch", "GetData", TextUtils.Caption, MessageLibrary._SystemMessage, ex.Message, MessageBoxIcon.Error);
                frm.ShowDialog();
                return;
            }
        }
Esempio n. 10
0
        public async Task <ResponseModel> Insert(ContractTypeModel model)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                if (await _context.ContractTypeRepository.CountAsync(m => m.Code == model.Code) > 0)
                {
                    response.ResponseStatus = Core.CommonModel.Enums.ResponseStatus.CodeExists;
                    return(response);
                }

                ContractType md = new ContractType();

                md.Code           = model.Code;
                md.Name           = model.Name;
                md.Description    = model.Description;
                md.AllowInsurance = model.AllowInsurance;
                md.AllowLeaveDate = model.AllowLeaveDate;
                md.Precedence     = model.Precedence;
                md.IsActive       = model.IsActive;
                md.CreateBy       = base.UserId;
                md.CreateDate     = DateTime.Now;
                md.Deleted        = false;

                await _context.ContractTypeRepository.AddAsync(md).ConfigureAwait(true);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Esempio n. 11
0
        public async Task <ResponseModel> Item(int id)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                ContractType md = await _context.ContractTypeRepository.FirstOrDefaultAsync(m => m.Id == id);

                ContractTypeModel model = new ContractTypeModel()
                {
                    Id             = md.Id,
                    Code           = md.Code,
                    Name           = md.Name,
                    Description    = md.Description,
                    AllowLeaveDate = md.AllowLeaveDate,
                    AllowInsurance = md.AllowInsurance,
                    Precedence     = md.Precedence,
                    IsActive       = md.IsActive,
                    RowVersion     = md.RowVersion,
                };

                response.Result = model;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Esempio n. 12
0
        public ContractTypeModel SaveContractType(ContractTypeModel objContractTypeModel)
        {
            var    objContractTypeRepository = new ContractTypeRepository();
            var    objContractType           = new ContractType();
            string action = "";

            try
            {
                if (objContractTypeModel.CTT_Id == 0)
                {
                    action = "I";
                    var saveContractType = _workorderems.spSetContractType(action, null, objContractTypeModel.CTT_ContractType, objContractTypeModel.CTT_Discription, objContractTypeModel.CTT_IsActive);
                }
                else
                {
                    action = "U";
                    var saveContractType = _workorderems.spSetContractType(action, objContractTypeModel.CTT_Id, objContractTypeModel.CTT_ContractType, objContractTypeModel.CTT_Discription, objContractTypeModel.CTT_IsActive);
                }


                objContractTypeModel.Result = Result.Completed;
            }
            catch (Exception ex)
            {
                Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public ContractTypeModel SaveContractType(String Action, int? CTT_Id, string CTT_ContractType, string CTT_Discription, bool IsActive)", "Exception While Saving Contract Type.", null);
                throw;
            }
            return(objContractTypeModel);
        }
Esempio n. 13
0
        public ActionResult SaveContractType(ContractTypeModel objContractTypeModel)
        {
            eTracLoginModel ObjLoginModel = null;

            ViewBag.AccountSection = true;
            if (Session["eTrac"] != null)
            {
                ObjLoginModel = (eTracLoginModel)(Session["eTrac"]);
            }
            try
            {
                var savedStatus = _IContractType.SaveContractType(objContractTypeModel);
                if (savedStatus.Result == Result.Completed)
                {
                    ViewBag.Message           = CommonMessage.SaveSuccessMessage();
                    ViewBag.AlertMessageClass = ObjAlertMessageClass.Success;
                    ModelState.Clear();
                }
                else
                {
                    ViewBag.Message           = CommonMessage.FailureMessage();
                    ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;// store the failure message in tempdata to display in view.
                }
                return(View("~/Areas/AdminSection/Views/ContractType/Index.cshtml"));
                //return Json(new { Message = ViewBag.Message, AlertMessageClass = ViewBag.AlertMessageClass }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                ViewBag.Message           = ex.Message;
                ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
                throw ex;
            }
        }
Esempio n. 14
0
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        ContractTypeModel model = this.contractType.GetModel(this.typeID);

        model.UserCodes = JsonHelper.Serialize(ContractManage_ContractType_RoleControl.userCodes.ToArray());
        this.contractType.Update(model);
        base.RegisterScript("window.close();");
    }
Esempio n. 15
0
    private string getContractName(string guid)
    {
        ContractType      contractType = new ContractType();
        ContractTypeModel model        = contractType.GetModel(guid);
        string            empty        = string.Empty;

        return(model.TypeName);
    }
Esempio n. 16
0
 private void InitUpdate()
 {
     if (!string.IsNullOrEmpty(this.typeId))
     {
         ContractTypeModel model = this.contractType.GetModel(this.typeId);
         this.txtTypeCode.Text     = model.TypeCode;
         this.txtTypeName.Text     = model.TypeName;
         this.txtInputPerson.Text  = model.InputPerson;
         this.txtInputDate.Text    = model.InputDate.ToString();
         this.txtNotes.Text        = model.Notes;
         this.ddlCBS.SelectedValue = model.CBSCode;
         this.txtTypeShort.Text    = model.TypeShort;
     }
 }
Esempio n. 17
0
    private string GetContractLimits(string ContractTypeId)
    {
        System.Collections.Generic.List <string> userCodes = new System.Collections.Generic.List <string>();
        userCodes.Add(base.UserCode);
        if (base.UserCode != "00000000")
        {
            userCodes.Add("00000000");
        }
        ContractType      contractType = new ContractType();
        ContractTypeModel model        = contractType.GetModel(ContractTypeId);

        if (model != null)
        {
            System.Collections.Generic.List <string> listFromJson = JsonHelper.GetListFromJson(model.UserCodes);
            listFromJson.ForEach(delegate(string userCode)
            {
                if (!userCodes.Contains(userCode))
                {
                    userCodes.Add(userCode);
                }
            });
        }
        string text = this.hdnProjectCode.Value.Trim();

        System.Collections.Generic.List <string> list = (System.Collections.Generic.List <string>) new PTPrjInfoZTBUserService().GetUser(text);
        list.ForEach(delegate(string userCode)
        {
            if (!userCodes.Contains(userCode))
            {
                userCodes.Add(userCode);
            }
        });
        System.Collections.Generic.List <string> userCodesByIDThroughPrjProperty = new PTPrjInfoZTBDetailService().getUserCodesByIDThroughPrjProperty(text);
        System.Collections.Generic.List <string> userCode2 = new PrivBusiDataRoleService().GetUserCode(text);
        userCodesByIDThroughPrjProperty.ForEach(delegate(string userCode)
        {
            if (!userCodes.Contains(userCode))
            {
                userCodes.Add(userCode);
            }
        });
        userCode2.ForEach(delegate(string userCode)
        {
            if (!userCodes.Contains(userCode))
            {
                userCodes.Add(userCode);
            }
        });
        return(JsonHelper.Serialize(userCodes.ToArray()));
    }
Esempio n. 18
0
 public ActionResult AddContractType()
 {
     try
     {
         ViewBag.AccountSection = true;
         ContractTypeModel objContractTypeModel = new ContractTypeModel();
         return(PartialView("AddContractType", objContractTypeModel));
     }
     catch (Exception ex)
     {
         ViewBag.Message           = ex;
         ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;
         throw ex;
     }
 }
Esempio n. 19
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     base.Response.Cache.SetNoStore();
     if (!this.Page.IsPostBack)
     {
         this.DataBindDepartment();
         ContractTypeModel model = this.contractType.GetModel(this.typeID);
         ContractManage_ContractType_RoleControl.userCodes = JsonHelper.GetListFromJson(model.UserCodes);
         if (ContractManage_ContractType_RoleControl.userCodes.Count > 0)
         {
             System.Collections.Generic.List <string> names = this.yhmc.GetNames(ContractManage_ContractType_RoleControl.userCodes);
             this.lblUserNames.Text = JsonHelper.Serialize(names.ToArray());
         }
     }
 }
Esempio n. 20
0
        public ContractTypeModel GetModel(string TypeID)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("SELECT * FROM Con_ContractType ");
            builder.Append(" WHERE TypeID=@TypeID");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@TypeID", SqlDbType.NVarChar, 50) };
            commandParameters[0].Value = TypeID;
            ContractTypeModel model = null;

            using (IDataReader reader = SqlHelper.ExecuteReader(CommandType.Text, builder.ToString(), commandParameters))
            {
                while (reader.Read())
                {
                    model = this.GetModel(reader);
                }
                return(model);
            }
        }
Esempio n. 21
0
        public virtual IActionResult Edit(ContractTypeModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContractType))
            {
                return(AccessDeniedView());
            }

            //try to get a store with the specified id
            var item = _contractTypeService.GetContractTypeById(model.Id);

            if (item == null)
            {
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                item = model.ToEntity(item);


                _contractTypeService.UpdateContractType(item);

                //activity log
                _customerActivityService.InsertActivity("EditContractType",
                                                        string.Format(_localizationService.GetResource("ActivityLog.EditContractType"), item.Id), item);



                SuccessNotification(_localizationService.GetResource("AppWork.Contracts.ContractType.Updated"));

                return(continueEditing ? RedirectToAction("Edit", new { id = item.Id }) : RedirectToAction("List"));
            }

            //prepare model
            model = _contractModelFactory.PrepareContractTypeModel(model, item, true);

            //if we got this far, something failed, redisplay form
            return(View(model));
        }
Esempio n. 22
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (grvData.FocusedRowHandle > -1)
            {
                SetInterface(true);
                isAdd = false;
                int ID = Convert.ToInt16(grvData.GetRowCellValue(grvData.FocusedRowHandle, "ID").ToString());
                ObjContractTypeMode     = (ContractTypeModel)ContractTypeBO.Instance.FindByPK(ID);
                cboStatus.SelectedIndex = Convert.ToInt16(grvData.GetRowCellValue(grvData.FocusedRowHandle, "Status"));
                txtName.Text            = grvData.GetRowCellValue(grvData.FocusedRowHandle, "Name").ToString();
                txtDebitDate.Text       = grvData.GetRowCellValue(grvData.FocusedRowHandle, "DebitDate").ToString();
                txtDueDate.Text         = grvData.GetRowCellValue(grvData.FocusedRowHandle, "DueDate").ToString();
                txtARDate.Text          = grvData.GetRowCellValue(grvData.FocusedRowHandle, "ARDate").ToString();
                txtTransactionCode.Text = grvData.GetRowCellValue(grvData.FocusedRowHandle, "ContractTypeIDs").ToString();

                byte _isBook = Convert.ToByte(grvData.GetRowCellValue(grvData.FocusedRowHandle, "IsBook"));
                if (_isBook == 1)
                {
                    chkIsBook.Checked = true;
                }
                else
                {
                    chkIsBook.Checked = false;
                }

                byte _isOTL = Convert.ToByte(grvData.GetRowCellValue(grvData.FocusedRowHandle, "IsOTL"));
                if (_isOTL == 1)
                {
                    chkIsOTL.Checked = true;
                }
                else
                {
                    chkIsOTL.Checked = false;
                }
            }
        }
Esempio n. 23
0
 public void Add(ContractTypeModel model)
 {
     this.dal.Add(null, model);
 }
Esempio n. 24
0
 public frmContractType()
 {
     _Model = new ContractTypeModel();
     InitializeComponent();
 }
Esempio n. 25
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //SqlConnection con = new SqlConnection(DBUtils.GetDBConnectionString());
                if (CheckValid())
                {
                    if (isAdd)//thêm
                    {
                        ContractTypeModel _model = new ContractTypeModel();
                        _model.Name = txtName.Text.Trim();
                        if (txtTransactionCode.Text.Trim() == "")
                        {
                            _model.ContractTypeIDs = "0";
                        }
                        else
                        {
                            _model.ContractTypeIDs = TextUtils.ToString(txtTransactionCode.Text);
                        }

                        if (txtDebitDate.Text.Trim() == "")
                        {
                            _model.DebitDate = 0;
                        }
                        else
                        {
                            _model.DebitDate = TextUtils.ToInt(txtDebitDate.Text);
                        }
                        if (txtDueDate.Text.Trim() == "")
                        {
                            _model.DueDate = 0;
                        }
                        else
                        {
                            _model.DueDate = TextUtils.ToInt(txtDueDate.Text);
                        }
                        if (txtARDate.Text.Trim() == "")
                        {
                            _model.ARDate = 0;
                        }
                        else
                        {
                            _model.ARDate = TextUtils.ToInt(txtARDate.Text);
                        }

                        _model.IsBook = chkIsBook.Checked;
                        _model.IsOTL  = chkIsOTL.Checked;


                        _model.Status      = cboStatus.SelectedIndex;
                        _model.CreatedBy   = Global.AppUserName;
                        _model.CreatedDate = TextUtils.GetSystemDate();
                        _model.UpdatedBy   = Global.AppUserName;
                        _model.UpdatedDate = TextUtils.GetSystemDate();
                        //_model.ContractTypeID = ContractTypeID;
                        ContractTypeBO.Instance.Insert(_model);
                    }
                    else//sửa
                    {
                        int ID = Convert.ToInt16(grvData.GetRowCellValue(grvData.FocusedRowHandle, "ID").ToString());

                        //ContractTypeModel _model = (ContractTypeModel)ContractTypeBO.Instance.FindByPK(ID);
                        if (this.ObjContractTypeMode != null)
                        {
                            ContractTypeModel _model = ObjContractTypeMode;
                            _model.Status = cboStatus.SelectedIndex;
                            _model.Name   = txtName.Text.Trim();
                            if (txtTransactionCode.Text.Trim() == "")
                            {
                                _model.ContractTypeIDs = "0";
                            }
                            else
                            {
                                _model.ContractTypeIDs = TextUtils.ToString(txtTransactionCode.Text);
                            }
                            if (txtDebitDate.Text.Trim() == "")
                            {
                                _model.DebitDate = 0;
                            }
                            else
                            {
                                _model.DebitDate = TextUtils.ToInt(txtDebitDate.Text);
                            }
                            if (txtDueDate.Text.Trim() == "")
                            {
                                _model.DueDate = 0;
                            }
                            else
                            {
                                _model.DueDate = TextUtils.ToInt(txtDueDate.Text);
                            }

                            _model.IsBook = chkIsBook.Checked;
                            _model.IsOTL  = chkIsOTL.Checked;

                            if (txtARDate.Text.Trim() == "")
                            {
                                _model.ARDate = 0;
                            }
                            else
                            {
                                _model.ARDate = TextUtils.ToInt(txtARDate.Text);
                            }

                            _model.UpdatedBy   = Global.AppUserName;
                            _model.UpdatedDate = TextUtils.GetSystemDate();

                            ContractTypeBO.Instance.Update(_model);
                        }
                    }
                    LoadData();
                    SetInterface(false);
                    ClearInterface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Thêm/Sửa bị lỗi, hãy thử lại\n\n" + ex.Message, TextUtils.Caption);
            }
        }
Esempio n. 26
0
 public void Add(SqlTransaction trans, ContractTypeModel model)
 {
     this.dal.Add(trans, model);
 }
Esempio n. 27
0
 public void Update(ContractTypeModel model)
 {
     this.dal.Update(model);
 }
Esempio n. 28
0
 public void UpdateCBSCode(SqlTransaction trans, ContractTypeModel model)
 {
     this.dal.UpdateCBSCode(trans, model);
 }
Esempio n. 29
0
        public async Task <ResponseModel> Delete([FromBody] ContractTypeModel model)
        {
            var response = await _contractTypeService.Delete(model);

            return(response);
        }
Esempio n. 30
0
    protected void btnSave_Click(object sender, System.EventArgs e)
    {
        ConContractTypeService conContractTypeService = new ConContractTypeService();
        ConContractType        conContractType        = new ConContractType();

        if (string.Compare(this.action, "Add", true) == 0)
        {
            conContractType = conContractTypeService.GetContractTypeByTypeName(this.txtTypeName.Text.Trim());
            if (conContractType != null)
            {
                base.RegisterScript("top.ui.alert('合同类型名称已经存在!')");
                return;
            }
            conContractType = conContractTypeService.GetContractTypeByTypeShort(this.txtTypeShort.Text.Trim());
            if (conContractType != null)
            {
                base.RegisterScript("top.ui.alert('合同类型简写已经存在!')");
                return;
            }
            ContractTypeModel contractTypeModel = new ContractTypeModel();
            contractTypeModel.TypeID   = System.Guid.NewGuid().ToString();
            contractTypeModel.TypeCode = this.txtTypeCode.Text.Trim();
            contractTypeModel.TypeName = this.txtTypeName.Text.Trim();
            if (base.UserCode == "00000000")
            {
                contractTypeModel.UserCodes = JsonHelper.Serialize(new string[]
                {
                    "00000000"
                });
            }
            else
            {
                contractTypeModel.UserCodes = JsonHelper.Serialize(new string[]
                {
                    "00000000",
                    base.UserCode
                });
            }
            contractTypeModel.Notes       = this.txtNotes.Text.Trim();
            contractTypeModel.InputPerson = this.txtInputPerson.Text;
            contractTypeModel.InputDate   = new System.DateTime?(System.Convert.ToDateTime(this.txtInputDate.Text));
            contractTypeModel.TypeShort   = this.txtTypeShort.Text.Trim();
            if (!string.IsNullOrEmpty(this.ddlCBS.SelectedValue.Trim()))
            {
                contractTypeModel.CBSCode = this.ddlCBS.SelectedValue.Trim();
            }
            else
            {
                contractTypeModel.CBSCode = null;
            }
            try
            {
                this.contractType.Add(contractTypeModel);
                base.RegisterScript("top.ui.tabSuccess({ parentName: '_ContractTypeEdit' });");
                return;
            }
            catch (System.Exception)
            {
                base.RegisterScript("top.ui.alert('添加失败')");
                return;
            }
        }
        string text    = base.Request["TypeID"].ToString();
        string cmdText = string.Concat(new string[]
        {
            "SELECT * FROM Con_ContractType WHERE TypeID not in('",
            text,
            "') and TypeName='",
            this.txtTypeName.Text.Trim(),
            "'"
        });
        DataTable dataTable = conContractTypeService.ExecuteQuery(cmdText, null);

        if (dataTable.Rows.Count > 0)
        {
            base.RegisterScript("top.ui.alert('合同类型名称已经存在!')");
            return;
        }
        cmdText = string.Concat(new string[]
        {
            "SELECT * FROM Con_ContractType WHERE TypeID not in('",
            text,
            "') and TypeShort='",
            this.txtTypeShort.Text.Trim(),
            "'"
        });
        dataTable = conContractTypeService.ExecuteQuery(cmdText, null);
        if (dataTable.Rows.Count > 0)
        {
            base.RegisterScript("top.ui.alert('合同类型简写已经存在!')");
            return;
        }
        ContractTypeModel model = this.contractType.GetModel(text);

        model.TypeCode  = this.txtTypeCode.Text.Trim();
        model.TypeName  = this.txtTypeName.Text.Trim();
        model.Notes     = this.txtNotes.Text.Trim();
        model.TypeShort = this.txtTypeShort.Text.Trim();
        if (!string.IsNullOrEmpty(this.ddlCBS.SelectedValue.Trim()))
        {
            model.CBSCode = this.ddlCBS.SelectedValue.Trim();
        }
        else
        {
            model.CBSCode = null;
        }
        try
        {
            this.contractType.Update(model);
            base.RegisterScript("top.ui.tabSuccess({ parentName: '_ContractTypeEdit' });");
        }
        catch (System.Exception)
        {
            base.RegisterScript("top.ui.alert('添加失败')");
        }
    }