コード例 #1
0
ファイル: HouseHireAppForm.xaml.cs プロジェクト: jjg0519/OA
        //private void SetReturnBar()
        //{
        //    ToolbarItems = CreateFormReturnButton();
        //    this.sDate.IsEnabled = false;
        //    this.eDate.IsEnabled = false;
        //    this.bDate.IsEnabled = true;
        //}

        private void Save()
        {
            try
            {
                string StrStartDt = ""; //开始时间

                string StrEndDt = "";   //结束时间
                string StrOutDt = "";   //退房时间
                if (houseList == null || houseList.houseInfoObj == null)
                {
                    Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("PLEASESELECT", "HOUSEMANAGERINFO"));
                }
                if (rbtWhole.IsChecked == true)
                {
                    StrRentType = "0";
                }
                if (RbtShared.IsChecked == true)
                {
                    StrRentType = "1";
                }
                if (rbtPay.IsChecked == true)
                {
                    StrSettlementType = "0";
                }
                if (RbtCash.IsChecked == true)
                {
                    StrSettlementType = "1";
                }
                if (!string.IsNullOrEmpty(this.sDate.Text.ToString()))
                {
                    StrStartDt = this.sDate.Text.ToString();
                }
                else
                {
                    Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("STARTTIMENOTNULL"));
                    return;
                }
                if (!string.IsNullOrEmpty(this.eDate.Text.ToString()))
                {
                    StrEndDt = this.eDate.Text.ToString();
                }
                else
                {
                    Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("ENDTIMENOTNULL"));
                    return;
                }

                DateTime DtStart = System.Convert.ToDateTime(StrStartDt);
                DateTime DtEnd   = System.Convert.ToDateTime(StrEndDt);

                if (DtStart >= DtEnd)
                {
                    Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("STARTTIMENOTGREATENDTIME"));
                    return;
                }
                StrOutDt = this.bDate.Text.ToString();
                if (FromFormFlag == "2") //退房
                {
                    if (string.IsNullOrEmpty(StrOutDt))
                    {
                        Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("BACKDATENOTNULL"));
                        return;
                    }
                }
                if (!string.IsNullOrEmpty(StrOutDt))
                {
                    DateTime DtOut = System.Convert.ToDateTime(StrOutDt);
                    if (DtStart >= DtOut)
                    {
                        Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("STARTTIMENOTGREATOUTTIME"));
                        return;
                    }
                    if (DtOut <= System.DateTime.Now)//退房时间不能小于当前时间
                    {
                        Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("CHECKOUTDATENOLESSTHANNOW"));
                        return;
                    }
                }

                if (Check())
                {
                    if (action != Action.Return)
                    {
                        hireApp.STARTDATE = Convert.ToDateTime(sDate.SelectedDate);
                        hireApp.ENDDATE   = Convert.ToDateTime(eDate.SelectedDate);
                    }
                    else
                    {
                        //hireApp.T_OA_HOUSEINFO.ISRENT = "0";
                        hireApp.BACKDATE = Convert.ToDateTime(bDate.SelectedDate);
                    }
                    houseInfo = houseList.houseInfoObj;
                    RefreshUI(RefreshedTypes.ShowProgressBar);
                    if (action == Action.Add)
                    {
                        hireApp.HIREAPPID      = Guid.NewGuid().ToString();
                        hireApp.CHECKSTATE     = ((int)CheckStates.UnSubmit).ToString();
                        hireApp.T_OA_HOUSELIST = houseList.houselistObj;

                        //hireApp.T_OA_HOUSELIST.HOUSELISTID = houseInfo.HOUSEID;
                        hireApp.MANAGECOST = System.Convert.ToInt32(txtManageCost.Text.ToString()); //houseInfo.MANAGECOST;//管理费


                        hireApp.DEPOSIT        = houseInfo.DEPOSIT;
                        hireApp.RENTCOST       = houseInfo.RENTCOST;
                        hireApp.RENTTYPE       = StrRentType;       //出租类型
                        hireApp.SETTLEMENTTYPE = StrSettlementType; //结算方式
                        hireApp.ISBACK         = "0";               //是否退房
                        hireApp.ISOK           = "0";               //是否确认

                        hireApp.STARTDATE = DtStart;
                        hireApp.ENDDATE   = DtEnd;

                        hireApp.CREATEUSERID       = Common.CurrentLoginUserInfo.EmployeeID;
                        hireApp.CREATEUSERNAME     = Common.CurrentLoginUserInfo.EmployeeName;
                        hireApp.CREATEPOSTID       = Common.CurrentLoginUserInfo.UserPosts[0].PostID;
                        hireApp.CREATEDEPARTMENTID = Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
                        hireApp.CREATECOMPANYID    = Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
                        hireApp.CREATEDATE         = DateTime.Now;

                        hireApp.OWNERID           = Common.CurrentLoginUserInfo.EmployeeID;
                        hireApp.OWNERNAME         = Common.CurrentLoginUserInfo.EmployeeName;
                        hireApp.OWNERPOSTID       = Common.CurrentLoginUserInfo.UserPosts[0].PostID;
                        hireApp.OWNERDEPARTMENTID = Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
                        hireApp.OWNERCOMPANYID    = Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;


                        client.AddHireAppAsync(hireApp, "Add");
                    }
                    else
                    {
                        hireApp.UPDATEDATE     = DateTime.Now;
                        hireApp.UPDATEUSERID   = Common.CurrentLoginUserInfo.EmployeeID;
                        hireApp.UPDATEUSERNAME = Common.CurrentLoginUserInfo.EmployeeName;
                        //hireApp.T_OA_HOUSELIST.HOUSELISTID = houseList.houselistObj.HOUSELISTID;
                        hireApp.T_OA_HOUSELIST = houseList.houselistObj;
                        hireApp.DEPOSIT        = houseInfo.DEPOSIT;
                        hireApp.RENTCOST       = houseInfo.RENTCOST;
                        if (FromFormFlag == "1")//入住
                        {
                            hireApp.ISOK = "1";
                        }
                        if (FromFormFlag == "2")//退房
                        {
                            hireApp.ISBACK   = "1";
                            hireApp.BACKDATE = bDate.SelectedDate;
                            if (bDate.SelectedDate <= sDate.SelectedDate)
                            {
                                Utility.ShowCustomMessage(MessageTypes.Message, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("RETURNDATENOTLESSSTARTDATE"));
                            }
                        }
                        hireApp.RENTTYPE       = StrRentType;       //出租类型
                        hireApp.SETTLEMENTTYPE = StrSettlementType; //结算方式

                        client.UpdateHireAppAsync(hireApp, "Edit");
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), ex.Message.ToString());
            }
        }