Ejemplo n.º 1
0
 void AddLineItem()
 {
     DataRow current = null;
     if (txtbarcode.EditValue != null)
     {
         var blf = new BlItemMaster().FindItemByBarCode(txtbarcode.EditValue.ToString());
         if (blf.Rows.Count == 0)
         {
             XtraMessageBox.Show("Item master not found", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtbarcode.SelectAll();
             return;
         }
         foreach (DataRow dr in blf.Rows)
         {
             current = dr;
         }
     }
     else
     {
         return;
     }
         _DISCONSALE = false;
         _discount = 0m;
         var SPRICE = 0m;
         var CPRICE = 0m;
         var purdiscout = 0m;
         if (!string.IsNullOrEmpty(current["DISCOUNT"].ToString()))
             purdiscout = decimal.Parse(current["DISCOUNT"].ToString());
         if (!string.IsNullOrEmpty(current["SPRICE"].ToString()))
             SPRICE = decimal.Parse(current["SPRICE"].ToString());
         if (!string.IsNullOrEmpty(current["CPRICE"].ToString()))
         {
             CPRICE = decimal.Parse(current["CPRICE"].ToString());
         }
         txtbarcode.EditValue = string.Empty;
         if (_isreturn)
         {
             DoReturn(current);
             return;
         }
         var bl = new BLSales();
         var aQty = bl.GetAvailableQty(current["ITEMNO"].ToString());
         if(aQty > 0)
         {
             CheckForMultiStock(current["ITEMNO"].ToString(),current["ITEMNAME"].ToString());
         }
         else
         {
             var dStockmasterRow = (DsInventory.STOCKMASTERRow)dsInventory1.STOCKMASTER.NewRow();
             dStockmasterRow.ITEMNO = current["ITEMNO"].ToString();
             dStockmasterRow.BARCODE = current["BARCODE"].ToString();
             dStockmasterRow.DQNTY = 1;
             dStockmasterRow.CPRICE = CPRICE;
             dStockmasterRow.QTY = 0;
             if (SPRICE == 0)
             {
                 SPRICE = new BLSales().GetSalesPriceByItemno(current["ITEMNO"].ToString());
             }
             var f = LoadQtyMoreForm(current["ITEMNO"].ToString(), current["ITEMNAME"].ToString(), aQty, 1, 0, 1, SPRICE, true, true, dStockmasterRow, purdiscout);
             if (f.iscontinue == 1)
             {
                 //GetStockItemBySprice
                 var dnewstock = new BLSales().GetStockItem(current["ITEMNO"].ToString(), "S");
                 if(f.salesprice !=SPRICE)
                 {
                     dnewstock = new BLSales().GetStockItemBySprice(current["ITEMNO"].ToString(),f.salesprice);
                 }
                 
                 foreach(DsInventory.STOCKMASTERRow dr in dnewstock.Rows)
                 {
                     dr.DQNTY = f.enterqty;
                 }
              // var topRows = dnewstock.AsEnumerable().OrderBy(o => o.Field<int>("STOCKID")).Take(1).ToList().CopyToDataTable();
                 string itemno = current["ITEMNO"].ToString();
                 var t = NotifyItems.Find(match => match == itemno);
                 if(t!=null)
                     NotifyItems.Add(itemno);
                  AddMultipleItems(dnewstock, current["ITEMNAME"].ToString(), f.isBlankStock);
             }
         }
         UpdateTotal();
         txtbarcode.EditValue = String.Empty;
     //}
 }