示例#1
0
        public void DoView()
        {
            if (!string.IsNullOrEmpty(_pono))
            {
                var bl = new BLPO { Pono = _pono };
                    bl.GetPo();
                var dr = bl.PomainRow;
                txtpurno.Text = _pono;
                
                LookupSupplier.EditValue = dr.SUPID;
                supadd.EditValue = dr.SUPADD;
                deladd.EditValue = dr.DELADD;
                invdate.EditValue = dr.TRANDATE;

                if (dr.isprint)
                {
                    Coptionbutton4Visibility = BarItemVisibility.Always;
                    Coptionbutton4Image = Resources.PrintOk;
                    Coptionbutton4Caption = "Re-Print";
                    RibbonSaveEnable = false;
                    BPrint.Visibility = BarItemVisibility.Never;
                    
                }
                else
                {
                   Coptionbutton4Visibility = BarItemVisibility.Never;
                   RibbonSaveEnable = true;
                   RibbonPrintVisible = true;
                   BPrint.Visibility = BarItemVisibility.Always;
                }
                if(!dr.IsflagrecNull())
                if(dr.flagrec=="R")
                {
                    lblreceived.Visible = true;
                    RibbonSaveEnable = false;
                }
                else
                {
                    RibbonPageEditVisible = true;
                }
                txtextradisc.EditValue = dr.EXTRDISC;
                txtnetamt.EditValue = dr.NETVALUE;
                Lookupwarehouse.EditValue = null;
                Lookupwarehouse.EditValue = dr.STORECODE;
                lookUpEdit1.EditValue = dr.PAYTERMS;

                if (dsPurchase1.PODETAIL.Rows.Count > 0)
                {
                    dsPurchase1.PODETAIL.Clear();
                    Functions.DeleteBackUp();
                    dsPurchase1.Merge(bl.Podetail);
                }
                else
                {
                    dsPurchase1.Merge(bl.Podetail);
                }
                UpdateTotals();
            }
        }
示例#2
0
 bool DoSave()
 {
         if (PurchaseOrderHasErrors())
         {
             XtraMessageBox.Show("Purchase order  not saved due to error", "POS",MessageBoxButtons.OK, MessageBoxIcon.Error);
             return false;
         }
     UpdateTotals();
     bool retval = false;
     var dr = (DsPurchase.POMAINRow) dsPurchase1.POMAIN.NewRow();
     dr.PONO = _pono;
     dr.TRANDATE = invdate.DateTime;
     dr.SUPID = LookupSupplier.EditValue.ToString();
     dr.SUPNAME = string.IsNullOrWhiteSpace(LookupSupplier.Text) ? null : LookupSupplier.Text;
     dr.SUPADD = supadd.EditValue == null ? string.Empty : supadd.EditValue.ToString();
     dr.STORECODE = Lookupwarehouse.EditValue == null ? null : Lookupwarehouse.EditValue.ToString();
     dr.DELADD = deladd.EditValue == null ? string.Empty : deladd.EditValue.ToString();
     dr.NETVALUE = txtnetamt.EditValue == null ? 0 : decimal.Parse(txtnetamt.EditValue.ToString());
     dr.EXTRDISC = txtextradisc.EditValue == null ? 0 : decimal.Parse(txtextradisc.EditValue.ToString());
     dr.supnote = supnote.EditValue==null?null:supnote.EditValue.ToString();
     dr.PAYTERMS = lookUpEdit1.EditValue == null ? 0 : int.Parse(lookUpEdit1.EditValue.ToString());
     var bhl = new BLPO();
     gridView1.PostEditor();
     gridView1.UpdateCurrentRow();
     pODETAILBindingSource.EndEdit();
     bhl.PomainRow = dr;
     var changes = (DsPurchase.PODETAILDataTable)dsPurchase1.PODETAIL.GetChanges(DataRowState.Modified | DataRowState.Added);
     bhl.Podetail = changes ?? dsPurchase1.PODETAIL;
     try
     {
         var saveStatus = bhl.DoSave();
         if (saveStatus == "1")
         {
             _pono = bhl.Pono;
             txtpurno.Text = _pono;
             RibbonSaveEnable = false;
             HoldButtonVisibility = BarItemVisibility.Never;
             XtraMessageBox.Show("Data Saved Sucessfully", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
             foreach (DataRow d in dsPurchase1.PODETAIL.Rows)
             {
                 if (d.RowState != DataRowState.Deleted)
                 {
                     d["PONO"] = bhl.Pono;
                 }
             }
             var addedRows = from row in dsPurchase1.PODETAIL
                             where row.RowState == DataRowState.Added
                             select row;
             foreach (var row in addedRows.ToArray())
             {
                 row.Delete();
             }
             if (changes != null) dsPurchase1.Merge(changes);
             dsInventory1.AcceptChanges();
             retval = true;
         }
         else
         {
             XtraMessageBox.Show(saveStatus, "POS", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.ToString());
     }
     SetNavigation();
     return retval;
 }