Example #1
0
        protected override void Save()
        {
            //保存前吧鼠标焦点置于 GridControl中,目的是触发一些控件的更改事件,比如说  供应商更改事件
            //如果控件修改完直接点击保存,对应的修改事件不触发
            this.gridControl1.Focus();

            if (!this.gridView1.PostEditor() || !this.gridView1.UpdateCurrentRow())
            {
                return;
            }

            this._produceOtherInDepot.ProduceOtherInDepotId   = this.textEditProduceOtherInDepotId.Text;
            this._produceOtherInDepot.ProduceOtherInDepotDesc = this.textEditProduceOtherInDepotDesc.Text;
            //this.produceOtherInDepot.WorkHouse = this.newChooseWorkHorseId.EditValue as Model.WorkHouse;
            //if (this.produceOtherInDepot.WorkHouse != null)
            //{
            //    this.produceOtherInDepot.WorkHouseId = this.produceOtherInDepot.WorkHouse.WorkHouseId;
            //}
            this._produceOtherInDepot.Supplier = this.newChooseContorlSipu.EditValue as Model.Supplier;
            if (this._produceOtherInDepot.Supplier != null)
            {
                this._produceOtherInDepot.SupplierId = this._produceOtherInDepot.Supplier.SupplierId;
            }
            if (global::Helper.DateTimeParse.DateTimeEquls(this.dateEditProduceOtherInDepotDate.DateTime, new DateTime()))
            {
                this._produceOtherInDepot.ProduceOtherInDepotDate = global::Helper.DateTimeParse.NullDate;
            }
            else
            {
                this._produceOtherInDepot.ProduceOtherInDepotDate = this.dateEditProduceOtherInDepotDate.DateTime;
            }
            this._produceOtherInDepot.Employee0 = BL.V.ActiveOperator.Employee;
            if (this._produceOtherInDepot.Employee0 != null)
            {
                this._produceOtherInDepot.Employee0Id = this._produceOtherInDepot.Employee0.EmployeeId;
            }
            this._produceOtherInDepot.Employee1 = (this.newChooseEmployee1.EditValue as Model.Employee);
            if (this._produceOtherInDepot.Employee1 != null)
            {
                this._produceOtherInDepot.Employee1Id = this._produceOtherInDepot.Employee1.EmployeeId;
            }
            this._produceOtherInDepot.Depot = this.newChooseContorlDepot.EditValue as Model.Depot;
            if (this._produceOtherInDepot.Depot != null)
            {
                this._produceOtherInDepot.DepotId = this._produceOtherInDepot.Depot.DepotId;
            }
            //this._produceOtherInDepot.InvoiceCusId = this.textEditCusXOId.Text;
            if (this.newChooseEmployeeUpdate.EditValue != null)
            {
                this._produceOtherInDepot.EmployeeUpdate   = this.newChooseEmployeeUpdate.EditValue as Model.Employee;
                this._produceOtherInDepot.EmployeeUpdateId = this._produceOtherInDepot.EmployeeUpdate.EmployeeId;
            }
            this._produceOtherInDepot.Employee0   = this.newChooseEmployee0.EditValue as Model.Employee;
            this._produceOtherInDepot.Employee0Id = this._produceOtherInDepot.Employee0.EmployeeId;
            if (this.newChooseEmployee1.EditValue != null)
            {
                this._produceOtherInDepot.Employee1   = this.newChooseEmployee1.EditValue as Model.Employee;
                this._produceOtherInDepot.Employee1Id = this._produceOtherInDepot.Employee1.EmployeeId;
            }
            this._produceOtherInDepot.AuditState    = this.saveAuditState;
            this._produceOtherInDepot.ProduceAmount = Convert.ToDouble(this.txt_Sum.Text == "" ? null : this.txt_Sum.Text);
            this._produceOtherInDepot.ProduceTax    = Convert.ToDouble(this.txt_Tax.Text == "" ? null : this.txt_Tax.Text);
            this._produceOtherInDepot.ProduceTotal  = Convert.ToDouble(this.txt_Total.Text == "" ? null : this.txt_Total.Text);

            this._produceOtherInDepot.PayDate        = this.PayDate.EditValue == null ? DateTime.Now : this.PayDate.DateTime;
            this._produceOtherInDepot.InvoiceTaxrate = (int)this.spe_InvoiceTaxrate.Value;

            Dictionary <string, string> dicSubject = new Dictionary <string, string>();

            //dicSubject.Add("進貨", null);
            dicSubject.Add(this.produceOtherInDepotManager.GetSubjectNameBySupplier(_produceOtherInDepot.Supplier), null);
            dicSubject.Add("進項稅額", null);
            dicSubject.Add(string.Format("應付帳款-{0}", this._produceOtherInDepot.Supplier.SupplierShortName), null);

            for (int i = 0; i < dicSubject.Count; i++)
            {
                string key   = dicSubject.Keys.ToArray()[i];
                string value = atAccountSubjectManager.GetSubjectIdByName(key);
                if (string.IsNullOrEmpty(value))
                {
                    if (i != 2)
                    {
                        throw new Exception(string.Format("會計科目中無此科目:{0},請先添加。", key));
                    }

                    try
                    {
                        BL.V.BeginTransaction();
                        //Model.AtAccountSubject atAccountSubject = new Model.AtAccountSubject();
                        //atAccountSubject.SubjectId = Guid.NewGuid().ToString();
                        //atAccountSubject.SubjectName = key;
                        //atAccountSubject.AccountingCategoryId = "31c7baf9-c21d-4075-8738-ebbaedd1c000";
                        //atAccountSubject.TheLending = "貸";
                        //atAccountSubject.TheBalance = 0;
                        //atAccountSubject.InsertTime = DateTime.Now;
                        //atAccountSubject.UpdateTime = DateTime.Now;
                        //atAccountSubject.Id = "select cast((select top 1 cast(Id as int) from AtAccountSubject where left(Id,4)='2144' order by Id desc )+1 as varchar(20))";
                        string subjectId = Guid.NewGuid().ToString();
                        string insertSql = string.Format("insert into AtAccountSubject values('{0}','{1}','',null,'31c7baf9-c21d-4075-8738-ebbaedd1c000','貸','0',null,null,null,null,GETDATE(),GETDATE(),(select cast((select top 1 cast(Id as int) from AtAccountSubject where left(Id,4)='2144' order by Id desc )+1 as varchar(20))),null,null)", subjectId, key);

                        this.produceOtherInDepotManager.UpdateSql(insertSql);
                        value = subjectId;

                        BL.V.CommitTransaction();
                    }
                    catch
                    {
                        BL.V.RollbackTransaction();
                        throw new Exception(string.Format("添加會計科目‘{0}’時出現錯誤,請聯繫管理員", key));
                    }
                }

                dicSubject[key] = value;
            }


            switch (this.action)
            {
            case "insert":
                this.produceOtherInDepotManager.Insert(this._produceOtherInDepot);

                this.produceOtherInDepotManager.InsertAtSummon(_produceOtherInDepot, dicSubject);
                break;

            case "update":
                this._produceOtherInDepot.EmployeeUpdate   = BL.V.ActiveOperator.Employee;
                this._produceOtherInDepot.EmployeeUpdateId = BL.V.ActiveOperator.EmployeeId;
                this.produceOtherInDepotManager.Update(this._produceOtherInDepot);

                this.produceOtherInDepotManager.UpdateAtSummon(_produceOtherInDepot, dicSubject);
                break;
            }
        }
Example #2
0
        protected override void Save(Helper.InvoiceStatus status)
        {
            this.invoice.InvoiceStatus = (int)status;
            this.invoice.InvoiceId     = this.textEditInvoiceId.Text;
            this.invoice.InvoiceDate   = this.dateEditInvoiceDate.DateTime;
            this.invoice.Employee0     = this.buttonEditEmployee.EditValue as Model.Employee;
            this.invoice.Supplier      = this.buttonEditCompany.EditValue as Model.Supplier;
            if (this.buttonEditDepot.EditValue != null)
            {
                this.invoice.Depot   = this.buttonEditDepot.EditValue as Model.Depot;
                this.invoice.DepotId = (this.buttonEditDepot.EditValue as Model.Depot).DepotId;
            }
            //this.invoice.InvoiceAbstract = this.textEditAbstract.Text;
            this.invoice.InvoiceNote = this.textEditNote.Text;
            this.invoice.InvoiceTax  = this.calcEditInvoiceTax1.Value;
            if (string.IsNullOrEmpty(this.spinEditInvoiceTaxRate1.Text))
            {
                this.invoice.InvoiceTaxRate = 0;
            }
            else
            {
                this.invoice.InvoiceTaxRate = double.Parse(this.spinEditInvoiceTaxRate1.Text);
            }
            this.invoice.InvoiceZongJi = this.calcEditInvoiceTotal0.Value;
            this.invoice.InvoiceHeJi   = this.calcEditInvoiceTotal1.Value;

            this.invoice.InvoiceZSE    = this.calcEditInvoiceZSE.Value;
            this.invoice.InvoiceOwed   = this.calcEditInvoiceTotal0.Value;
            this.invoice.InvoiceLRTime = DateTime.Now;

            this.invoice.InvoiceCpbh         = this.textEditInvoiceCphm.Text;
            this.invoice.InvoiceKslb         = this.comboBoxEditInvoiceKslb.Text;
            this.invoice.InvoiceKlfs         = this.comboBoxEditInvoiceKlfs.Text;
            this.invoice.InvoiceKpls         = this.comboBoxEditInvoiceFpls.Text;
            this.invoice.InvoiceFpje         = this.spinEditInvoiceFpje.Value;
            this.invoice.InvoiceFpbh         = this.textEditInvoiceFpbh.Text;
            this.invoice.InvoicePayTimeLimit = this.dateEditInvoicePayTimeLimit.DateTime.Date;
            this.invoice.InvoiceZRE          = this.spinEditInvoiceZKE.Value;

            this.invoice.Employee1 = this.buttonEditEmployee1.EditValue as Model.Employee;
            this.invoice.Employee2 = this.buttonEditEmployee2.EditValue as Model.Employee;

            this.invoice.AuditState = this.saveAuditState;

            this.invoice.PayDate = this.PayDate.EditValue == null ? DateTime.Now : this.PayDate.DateTime;

            if (!this.gridView1.PostEditor() || !this.gridView1.UpdateCurrentRow())
            {
                return;
            }

            Dictionary <string, string> dicSubject = new Dictionary <string, string>();

            //dicSubject.Add("進貨", null);
            dicSubject.Add(this.invoiceManager.GetSubjectNameBySupplier(invoice.Supplier), null);
            dicSubject.Add("進項稅額", null);
            dicSubject.Add(string.Format("應付帳款-{0}", invoice.Supplier.SupplierShortName), null);

            for (int i = 0; i < dicSubject.Count; i++)
            {
                string key   = dicSubject.Keys.ToArray()[i];
                string value = atAccountSubjectManager.GetSubjectIdByName(key);
                if (string.IsNullOrEmpty(value))
                {
                    if (i != 2)
                    {
                        throw new Exception(string.Format("會計科目中無此科目:{0},請先添加。", key));
                    }

                    try
                    {
                        BL.V.BeginTransaction();
                        string subjectId = Guid.NewGuid().ToString();
                        string insertSql = string.Format("insert into AtAccountSubject values('{0}','{1}','',null,'31c7baf9-c21d-4075-8738-ebbaedd1c000','貸','0',null,null,null,null,GETDATE(),GETDATE(),(select cast((select top 1 cast(Id as int) from AtAccountSubject where left(Id,4)='2144' order by Id desc )+1 as varchar(20))),null,null)", subjectId, key);

                        this.invoiceManager.UpdateSql(insertSql);
                        value = subjectId;

                        BL.V.CommitTransaction();
                    }
                    catch
                    {
                        BL.V.RollbackTransaction();
                        throw new Exception(string.Format("添加會計科目‘{0}’時出現錯誤,請聯繫管理員", key));
                    }
                }

                dicSubject[key] = value;
            }

            switch (this.action)
            {
            case "insert":
                this.invoiceManager.Insert(this.invoice);

                this.invoiceManager.InsertAtSummon(invoice, dicSubject);
                break;

            case "update":
                this.invoiceManager.Update(this.invoice);

                this.invoiceManager.UpdateAtSummon(invoice, dicSubject);
                break;
            }
        }