Exemplo n.º 1
0
        private void AddInfo()
        {
            if (Check() == false)
            {
                return;
            }
            T_SYS_DICTIONARY StrDepCity = cmbUserFlag.SelectedItem as T_SYS_DICTIONARY;

            oCard_upd.Clear();
            oCard_add.Clear();

            if (newInfo == null)
            {
                newInfo = new T_OA_VEHICLE();
            }

            newInfo.ASSETID            = txtVehicleAssetId.Text;
            newInfo.BUYDATE            = Convert.ToDateTime(dpBuyDate.Text);
            newInfo.BUYPRICE           = Convert.ToDecimal(txtPrice.Text);
            newInfo.INITIALRANGE       = Convert.ToDecimal(txtINITIALRANGE.Text);
            newInfo.INTERVALRANGE      = Convert.ToDecimal(txtINTERVALRANGE.Text);
            newInfo.MAINTAINCOMPANY    = txtMAINTAINCOMPANY.Text;
            newInfo.MAINTAINTEL        = txtMAINTAINTEL.Text;
            newInfo.MAINTENANCECYCLE   = Convert.ToDecimal(txtMAINTENANCECYCLE.Text);
            newInfo.MAINTENANCEREMIND  = Convert.ToDecimal(txtMAINTENANCEREMIND.Text);
            newInfo.SEATQUANTITY       = Convert.ToDecimal(txtSEATQUANTITY.Text);
            newInfo.VEHICLEBRANDS      = txtVEHICLEBRANDS.Text;
            newInfo.VEHICLETYPE        = txtVEHICLETYPE.Text;
            newInfo.WEIGHT             = Convert.ToDecimal(txtWEIGHT.Text);
            newInfo.COMPANYID          = txtCompanyID.Text;
            newInfo.CREATECOMPANYID    = Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
            newInfo.CREATEDATE         = System.DateTime.Now;
            newInfo.CREATEDEPARTMENTID = Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
            newInfo.CREATEPOSTID       = Common.CurrentLoginUserInfo.UserPosts[0].PostID;
            newInfo.CREATEUSERID       = Common.CurrentLoginUserInfo.EmployeeID;
            newInfo.CREATEUSERNAME     = Common.CurrentLoginUserInfo.EmployeeName;

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

            if (cmbUserFlag.SelectedIndex != 0)
            {
                newInfo.VEHICLEFLAG = StrDepCity.DICTIONARYVALUE.ToString();
            }
            newInfo.VEHICLEMODEL = txtCarModel.Text;
            newInfo.VIN          = txtVIN.Text;

            //停车卡
            foreach (T_OA_VEHICLECARD card in dg.ItemsSource)
            {
                card.T_OA_VEHICLE = newInfo;
                if (card.VEHICLECARDID == null && (card.CARDNAME != null || card.CHARGEMONEY != null || card.CONTENT != null))
                {
                    card.VEHICLECARDID = Guid.NewGuid().ToString();

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

                    card.OWNERCOMPANYID    = Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
                    card.OWNERDEPARTMENTID = Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
                    card.OWNERID           = Common.CurrentLoginUserInfo.EmployeeID;
                    card.OWNERNAME         = Common.CurrentLoginUserInfo.EmployeeName;
                    card.OWNERPOSTID       = Common.CurrentLoginUserInfo.UserPosts[0].PostID;
                    if (card.CHARGEMONEY != null && card.CARDNAME != null)
                    {
                        oCard_add.Add(card);
                    }
                }
                else
                {
                    card.UPDATEDATE     = DateTime.Now;
                    card.UPDATEUSERID   = Common.CurrentLoginUserInfo.EmployeeID;
                    card.UPDATEUSERNAME = Common.CurrentLoginUserInfo.EmployeeName;
                    if (card.CHARGEMONEY != null && card.CARDNAME != null)
                    {
                        oCard_upd.Add(card);
                    }
                }
            }

            if (newInfo.VEHICLEID == null)
            {
                newInfo.VEHICLEID = Guid.NewGuid().ToString();
                _VM.AddVehicleAsync(newInfo);
            }
            else
            {
                newInfo.UPDATEDATE     = System.DateTime.Now;
                newInfo.UPDATEUSERID   = Common.CurrentLoginUserInfo.EmployeeID;
                newInfo.UPDATEUSERNAME = Common.CurrentLoginUserInfo.EmployeeName;
                _VM.UpdateVehicleAsync(newInfo);
            }
        }