示例#1
0
        void DoSave(bool SaveEdit)
        {
            if (!DoValidate())
            {
                var sup = new Supplier();
                sup.DsContact = dsMaster1.CONTACTMAST;
                sup.SUPPLIERNAME = vendorname.Text.Replace("'", "");
                sup.ARSUPPLIERNAME = string.Empty;
                sup.ALTERNATENAME = aliasname.Text;
                sup.ADDRESS = address.Text; //1500,
                sup.PHONE = phoneno.Text;
                sup.FAX = faxno.Text;//15
                sup.ACTIVE = bool.Parse(status.Checked.ToString());
                sup.CONTACAT = contact.Text;
               
                sup.EMAILID = email.Text;
                sup.WEBPAGE = webpage.Text; //60
                if (duedays.EditValue != null)
                    sup.DUEDAYS = int.Parse(duedays.EditValue.ToString());

                sup.VENDORSINCE = vendorsince.EditValue != null ? DateTime.Parse(vendorsince.EditValue.ToString()) : new DateTime(1900, 1, 1);
                sup.ACCOUNTNO = accountno.Text;
                if (!string.IsNullOrEmpty(balanceasof.Text))
                    sup.BALANCE = decimal.Parse(balance.Value.ToString());
                if (balanceasof.EditValue != null)
                    sup.BALANCEASOF = DateTime.Parse(balanceasof.EditValue.ToString());
                else
                {
                    sup.BALANCEASOF = new DateTime(1900, 1, 1); //SqlDateTime.Null;  
                }
                sup.NOTE = notes.Text;

                if (c1Expense.EditValue!=null)
                    sup.EXPACCID = int.Parse(c1Expense.EditValue.ToString());
                if (c1Grouping.EditValue != null)
                    sup.SUPGROUP = int.Parse(c1Grouping.EditValue.ToString());
                if (creditlimit.EditValue!=null)
                    sup.CREDITLIMIT = decimal.Parse(creditlimit.EditValue.ToString());
                if (c1Shipping.EditValue != null)
                    sup.DEFSHIPPING = int.Parse(c1Shipping.EditValue.ToString());
                if (c1Payment.EditValue!=null)
                    sup.DEFPAYMENT = int.Parse(c1Payment.EditValue.ToString());
                if (c1Terms.EditValue!=null)
                    sup.PAYTERMS = int.Parse(c1Terms.EditValue.ToString());
                var t = new SupplierManager();
                if(string.IsNullOrEmpty(supplierno))
                {
                    string r = t.AddSupplier(sup);
                    if (r =="1")
                    {
                        supplierno = Utils.SupplierNo;
                        vendorno.Text = Utils.SupplierNo;
                        XtraMessageBox.Show("Supplier Created", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    sup.SUPPLIERNO = supplierno;
                    foreach (DataRow d in dsMaster1.CONTACTMAST.Rows)
                        {
                            d["REFID"] = supplierno;
                            d["CONTTYPE"] = 2;
                        }
                    sup.DsContact = dsMaster1.CONTACTMAST;
                    bool flag = t.UpdateSupplier(sup);
                    XtraMessageBox.Show("Supplier updated", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
示例#2
0
        void DoSave(bool SaveEdit)
        {
            if (!DoValidate())
            {
                var sup = new Supplier();
                sup.DsContact = this.dSPOSSTORE.CONTACTMAST;
                sup.SUPPLIERNAME = vendorname.Text.Replace("'","") ;
                sup.ARSUPPLIERNAME=string.Empty;
                sup.ALTERNATENAME = aliasname.Text;
                sup.ADDRESS=address.Text   ; //1500,
                sup.PHONE=phoneno.Text;
                sup.FAX = faxno.Text ;//15
                sup.ACTIVE = bool.Parse(status.Checked.ToString());
                sup.CONTACAT = contact.Text;
                sup.DUEDAYS = (int) duedays.EditValue;
                sup.EMAILID = email.Text;
                sup.WEBPAGE= webpage.Text; //60
                if (duedays.EditValue != null)
                    sup.DUEDAYS = int.Parse(duedays.EditValue.ToString());
                if (vendorsince.EditValue != null)
                    //    if (!string.IsNullOrEmpty(vendorsince.EditValue.ToString()))
                    sup.VENDORSINCE =  DateTime.Parse(vendorsince.EditValue.ToString());
                else
                {

                    sup.VENDORSINCE = new DateTime(1900, 1, 1); //SqlDateTime.Null;  
                }
                //sup.VENDORSINCE =  vendorsince.Value.Date; 
                sup.ACCOUNTNO = accountno.Text;
                if(!string.IsNullOrEmpty(balanceasof.Text))
                        sup.BALANCE= decimal.Parse(balance.Value.ToString());
                //if(!string.IsNullOrEmpty(balanceasof.EditValue.ToString()))

                if (balanceasof.EditValue != null)
                    sup.BALANCEASOF = DateTime.Parse(balanceasof.EditValue.ToString());
                    
                else
                {

                    sup.BALANCEASOF = new DateTime(1900, 1, 1); //SqlDateTime.Null;  
                }
                sup.NOTE = notes.Text;

                if(!string.IsNullOrEmpty(c1Expense.SelectedText.ToString()))
                    sup.EXPACCID= int.Parse(c1Expense.SelectedValue.ToString()) ;
                if (!string.IsNullOrEmpty(c1Grouping.SelectedText.ToString()))
                    sup.SUPGROUP =int.Parse(c1Grouping.SelectedValue.ToString());
                sup.CREDITLIMIT = decimal.Parse(creditlimit.Value.ToString());
                if (!string.IsNullOrEmpty(c1Shipping.SelectedText.ToString()))
                     sup.DEFSHIPPING =  int.Parse(c1Shipping.SelectedValue.ToString()) ;
                if (!string.IsNullOrEmpty(c1Payment.SelectedText.ToString()))
                    sup.DEFPAYMENT = int.Parse(c1Payment.SelectedValue.ToString());
                if (!string.IsNullOrEmpty(c1Terms.SelectedText.ToString()))
                    sup.PAYTERMS = int.Parse(c1Terms.SelectedValue.ToString());
                var t = new SupplierManager();
                if (SaveEdit)
                {
                    string Returnval = t.AddSupplier(sup);
                    XtraMessageBox.Show(Returnval);
                }
                else
                {
                    sup.SUPPLIERNO = supplierno;
                    bool flag = t.UpdateSupplier(sup);
                    if (flag)
                    {
                        foreach (DataRow d in dSPOSSTORE.CONTACTMAST.Rows)
                        {
                            d["REFID"] = supplierno;
                            d["CONTTYPE"] = 2;
                        }
                        this.cONTACTMASTTableAdapter.Update(this.dSPOSSTORE.CONTACTMAST);
                        foreach (DataRow d in dSPOSSTORE.ADDRESSMAST.Rows)
                        {
                            d["REFID"] = supplierno;
                            d["CONTTYPE"] = 2;
                        }
                        this.addressmastTableAdapter1.Update(this.dSPOSSTORE.ADDRESSMAST);
                    }
                }
            }
        }