Esempio n. 1
0
 void DoView()
 {
     if (!string.IsNullOrEmpty(_Adjid))
     {
         var bl = new BLInventoryAdj { Adjid = _Adjid };
         bl.GetInventoryByTranid();
         textBox1.Text =_Adjid;
         invdate.EditValue = bl.AdjmastRow.TRANDATE;
         Lookupwarehouse.EditValue = bl.AdjmastRow.STORECODE;
         reason.SelectedIndex = bl.AdjmastRow.REASON;
         if (dsInventory1.ADJDETAIL.Rows.Count > 0)
         {
             dsInventory1.ADJDETAIL.Clear();
             dsInventory1.Merge(bl.AdjdetailDataTable);
         }
         else
         {
             dsInventory1.Merge(bl.AdjdetailDataTable);
         }
     }
     RibbonSaveEnable = false;
     _disableshortcut = true;
 }
Esempio n. 2
0
 bool DoSave()
 {
     if(DoValidation())
         return false;
     var bl = new BLInventoryAdj();
     advBandedGridView1.UpdateCurrentRow();
     var dr = (DsInventory.ADJMASTRow)dsInventory1.ADJMAST.NewRow();
     dr.ADJID = _Adjid;
     dr.TRANDATE = invdate.DateTime;
     dr.STORECODE = Lookupwarehouse.EditValue.ToString();
     dr.REASON = reason.SelectedIndex;
     bl.AdjmastRow = dr;
     //bl.AdjdetailDataTable = dsInventory1.ADJDETAIL;
     var changes = (DsInventory.ADJDETAILDataTable)dsInventory1.ADJDETAIL.GetChanges(DataRowState.Modified | DataRowState.Added);
     bl.AdjdetailDataTable = changes;
     try
     {
         var saveStatus = bl.DoSave();
         if (saveStatus == "1")
         {
             _Adjid = bl.Adjid;
             textBox1.Text = _Adjid;
             _disableshortcut = true;
             XtraMessageBox.Show("Data Saved Sucessfully", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
             foreach (DataRow d in dsInventory1.ADJDETAIL.Rows)
             {
                 if (d.RowState != DataRowState.Deleted)
                 {
                     d["ADJID"] = bl.Adjid;
                 }
             }
             var addedRows = from row in dsInventory1.ADJDETAIL
                             where row.RowState == DataRowState.Added
                             select row;
             foreach (var row in addedRows.ToArray())
             {
                 row.Delete();
             }
             if (changes != null) dsInventory1.Merge(changes);
             dsInventory1.AcceptChanges();
         }
         else
         {
             XtraMessageBox.Show(saveStatus, "POS", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return false;
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.ToString(), "POS", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
    return true;
 }