Beispiel #1
0
 public void DoView()
 {
     if (string.IsNullOrEmpty(Purid)) return;
     var bl = new Blpurretinv { Retinvid = Purid };
     bl.GetPurRetinv();
     txtpurno.Text = Purid;
     LookupSupplier.EditValue = bl.Supid == "0" ? null : bl.Supid;
     invno.EditValue = bl.Invno;
     invdate.EditValue = bl.Invdate;
     duedays.EditValue = bl.Duedays;
     spdisc.EditValue = bl.Spdiscount;
     adjustval.EditValue = bl.Adjvalue;
     ShorcutKeysDisbale = !bl.Hold;
     Lookupwarehouse.EditValue = null;
     Lookupwarehouse.EditValue = bl.Whid;
     if (dsPurchase1.RETURNDETAIL.Rows.Count > 0)
     {
         dsPurchase1.RETURNDETAIL.Clear();
         Functions.DeleteBackUp();
         dsPurchase1.Merge(bl.Retinvdetail);
     }
     else
     {
         dsPurchase1.Merge(bl.Retinvdetail);
     }
     UpdateTotals();
 }
Beispiel #2
0
 //string GetBarCodeFromQuery(IEnumerable<DataRow> qry)
 //{
 //    DataTable tb = qry.CopyToDataTable<DataRow>();
 //    return tb.Rows[0]["BARCODE"].ToString();
 //}
 bool DoSave()
 {
     bool retval = false;
     if (!IsHold)
     {
         PurchaseInvoceHasErrors();
         ValidateStock();
         if(dsPurchase1.PURINVDETAIL.HasErrors)
         {
             XtraMessageBox.Show("Invoice not saved due to error, please check the errors", "POS",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
             return false;
         }
     }
     UpdateTotals();
     var dr = (DsPurchase.RETURNMASTRow)dsPurchase1.RETURNMAST.NewRow();
     if (!string.IsNullOrEmpty(Purid))
         dr.RETURNID = Purid;
     dr.COMPANY = Utils.Company;
     dr.SUPID = LookupSupplier.EditValue == null ? null : LookupSupplier.EditValue.ToString();
     dr.SUPNAME = string.IsNullOrWhiteSpace(LookupSupplier.Text) ? null : LookupSupplier.Text;
     dr.INVNO = invno.EditValue == null ? null : invno.EditValue.ToString();
     dr.INVDATE = invdate.DateTime;
     dr.SPDISCOUNT = spdisc.EditValue == null ? 0 : decimal.Parse(spdisc.EditValue.ToString());
     dr.ADJVALUE = adjustval.EditValue == null ? 0 : decimal.Parse(adjustval.EditValue.ToString());
     dr.NETVALUE = totnetamt.EditValue == null ? 0 : decimal.Parse(totnetamt.EditValue.ToString());
     dr.WHID = Lookupwarehouse.EditValue == null ? string.Empty : Lookupwarehouse.EditValue.ToString();
     dr.HOLD = IsHold;
     dr.USERID = Utils.Userid;
     var bhl = new Blpurretinv(dr);
     advBandedGridView1.PostEditor();
     advBandedGridView1.UpdateCurrentRow();
     rETURNDETAILBindingSource.EndEdit();
     var changes = (DsPurchase.RETURNDETAILDataTable)dsPurchase1.RETURNDETAIL.GetChanges(DataRowState.Modified | DataRowState.Added);
     bhl.Retinvdetail =  dsPurchase1.RETURNDETAIL; 
     try
     {
         var strstatus = bhl.DoSave();
         if (strstatus == "1")
         {
             Purid = bhl.Retinvid;
             txtpurno.Text = Purid;
             RibbonSaveEnable = false;
             HoldButtonVisibility = BarItemVisibility.Never;
             XtraMessageBox.Show("Data Saved Sucessfully", "POS", MessageBoxButtons.OK,MessageBoxIcon.Information);
             foreach (DataRow d in dsPurchase1.RETURNDETAIL.Rows)
             {
                 if (d.RowState != DataRowState.Deleted)
                 {
                     d["RETURNID"] = bhl.Retinvid;
                 }
             }
             var addedRows = from row in dsPurchase1.RETURNDETAIL
                             where row.RowState == DataRowState.Added
                             select row;
             foreach (var row in addedRows.ToArray())
             {
                 row.Delete();
             }
             if (changes != null) dsPurchase1.Merge(changes);
             dsInventory1.AcceptChanges();
             Functions.DeleteBackUp();
             retval = true;
         }
         else
         {
             XtraMessageBox.Show(strstatus);
         }
     }
     catch (Exception ex)
     {
         Functions.CreateBackUp(dsPurchase1.RETURNDETAIL);
         XtraMessageBox.Show(ex.ToString());
     }
     SaveRequired = !retval;
     return retval;
 }