private void ResetForm()
        {
            rs = new ReceivedSummary();
             rgPricing_EditValueChanged(null, null);
            //txtUnpricedCost.EditValue = rs.UnPricedCost;
            //txtUnPricedQty.EditValue = rs.UnPricedQuantity;
            //txtPricedQty.EditValue = rs.PricedQuantity;
            //txtPricedCost.EditValue = rs.PricedTotalCost;
            //txtCurrentSellingValue.EditValue = rs.PricedSellingPrice;
            //txtPricePerPackage.EditValue = rs.SellingPricePerPackage;
            //txtTotalQuantity.EditValue = rs.TotalQuantity;
            //txtTotalCost.EditValue = rs.TotalCost;

            //txtUnitCost.EditValue = rs.TotalCost / rs.TotalQuantity;

            //txtMargin.EditValue = rs.Margin;
            //txtNewPrice.EditValue = rs.NewPrice;
            //txtNewPricePerPack.EditValue = rs.NewPricePerPack;
        }
        private void LoadDetail()
        {
            LoadDecimalFormatings();
            rs = new ReceivedSummary();

            gridCostSheet.DataSource = rs.MovingAverageTable(ItemID,StoreID,SupplierID, ManufacturerID, UnitID);
            txtAverageCost.EditValue = rs.NewUnitCost;
            txtMargin.EditValue = rs.Margin;
            txtSellingPrice.EditValue = rs.NewSellingPrice;
             //   .EditValue = rs.NewSellingPrice;
        }
        private void BindDetails(DataRow dr)
        {
            // txtAdditionalCost.EditValue = 0;
            //txtMargin.EditValue = 100;

            try
            {
                Convert.ToInt16(dr["ItemID"]);
            }
            catch
            {
                ResetForm();
                return;
            }

            if (dr != null)
            {
                rs = new ReceivedSummary();
                ReceiveDoc rd = new ReceiveDoc();
                rs.ItemID = Convert.ToInt32(dr["ItemID"]);
                rs.SupplierID = Convert.ToInt32(dr["SupplierID"]);
                rs.ManufacturerID = Convert.ToInt32(dr["ManufacturerID"]);
                rs.UnitID= null;
                if (dr["UnitID"] != DBNull.Value)
                {
                    rs.UnitID = Convert.ToInt32(dr["UnitID"]);
                }
                rs.StoreID = Convert.ToInt32(lkAccount.EditValue);

                // TODO: fix this ( Remove ) try cache
                try
                {
                    txtUnit.Text = dr["Unit"].ToString();
                }
                catch
                {

                }

                txtItemName.Text = dr["FullItemName"].ToString();
                txtManufacturer.Text = dr["Manufacturer"].ToString();

                rd.LoadForPricing(rs.ItemID, rs.SupplierID,rs.StoreID, rs.ManufacturerID, rs.UnitID);
                gridAllSimilarItems.DataSource = rd.DefaultView;

                LoadDecimalFormatings();

                rs.MovingAverageTable(rs.ItemID, rs.StoreID,rs.SupplierID, rs.ManufacturerID, rs.UnitID);
                txtAverageCost.EditValue = rs.NewUnitCost;
                txtMargin.EditValue = rs.Margin;
                txtSellingPrice.EditValue = rs.NewSellingPrice;

            }
        }
        /// <summary>
        /// Confirms the moving average.
        /// </summary>
        /// <param name="rs">The rs.</param>
        /// <param name="userID">The user ID.</param>
        public void ConfirmMovingAverage(ReceivedSummary rs, int userID)
        {
            FlushData();
            string query = "";

            query = HCMIS.Repository.Queries.ReceiveDoc.UpdateConfirmMovingAverage(rs.ItemID, rs.SupplierID, rs.StoreID, rs.ManufacturerID, userID, rs.UnitID);
            LoadFromRawSql(query);
        }
 private void ResetForm()
 {
     rs = new ReceivedSummary();
     rgPricing_EditValueChanged(null, null);
 }
        /// <summary>
        /// Sets the cost and selling price and send to confirmation.
        /// </summary>
        /// <param name="rs">The rs.</param>
        /// <param name="userID">The user ID.</param>
        public void SetCostAndSellingPriceAndSendToConfirmation(ReceivedSummary rs, int userID)
        {
            string query = "";
            query = HCMIS.Repository.Queries.ReceiveDoc.UpdateSetCostAndSellingPriceAndSendToConfirmationReceiveDoc(rs.NewUnitCost, BLL.Settings.NoOfDigitsAfterTheDecimalPoint, rs.ItemID, rs.SupplierID, rs.StoreID, rs.ManufacturerID, rs.UnitID, rs.NewSellingPrice, rs.Margin);
            LoadFromRawSql(query);

            query = HCMIS.Repository.Queries.ReceiveDoc.UpdateSetCostAndSellingPriceAndSendToConfirmationReceiveDocConfirmation(rs.ItemID, rs.SupplierID, rs.StoreID, rs.ManufacturerID, rs.UnitID, userID);
            LoadFromRawSql(query);
        }
 /// <summary>
 /// Sets the price per pack cost and selling price.
 /// </summary>
 /// <param name="rs">The rs.</param>
 public void SetPricePerPackCostAndSellingPrice(ReceivedSummary rs)
 {
     //Set Receivedoc Including The beginning Balance Initial Price Setting is Done here
     string query = "";
     query = HCMIS.Repository.Queries.ReceiveDoc.UpdateSetPricePerPackCostAndSellingPrice(rs.ItemID, rs.SupplierID, rs.NewUnitCost, rs.StoreID, rs.ManufacturerID, rs.UnitID, rs.NewSellingPrice, rs.Margin, query, BLL.Settings.NoOfDigitsAfterTheDecimalPoint);
     LoadFromRawSql(query);
 }
 /// <summary>
 /// Sends to finance manager confirmation.
 /// </summary>
 /// <param name="rs">The rs.</param>
 /// <param name="userID">The user ID.</param>
 public void SendToFinanceManagerConfirmation(ReceivedSummary rs, int userID)
 {
     string query = "";
     query = HCMIS.Repository.Queries.ReceiveDoc.UpdateSendToFinanceManagerConfirmation(userID, rs.ItemID, rs.SupplierID, rs.StoreID, rs.ManufacturerID, rs.UnitID);
     LoadFromRawSql(query);
 }
        public void SavePrice(CostElement costElement, int userID)
        {
            ReceivedSummary receivedSummary = new ReceivedSummary();
            receivedSummary.ItemID = costElement.ItemID;
            receivedSummary.UnitID = costElement.ItemUnitID;
            receivedSummary.ManufacturerID = costElement.ManufacturerID;
            receivedSummary.StoreID = costElement.MovingAverageID;
            receivedSummary.NewUnitCost = costElement.AverageCost;
            receivedSummary.Margin = costElement.Margin;
            receivedSummary.NewSellingPrice = costElement.SellingPrice;
            receivedSummary.NewPrice = costElement.AverageCost;
            receivedSummary.Remark = "Price override";
            FlushData();
            if (BLL.Settings.SkipBeginningBalancePricing)
            {
                SetPricePerPackCostAndSellingPrice(receivedSummary);
                SendToFinanceManagerConfirmation(receivedSummary, userID);
            }
            else

                SetCostAndSellingPriceAndSendToConfirmation(receivedSummary, userID);

            if (!BLL.Settings.IsCenter)
            {
                PricePicklistforHub(receivedSummary);

            }
            else
            {
                PricePicklistforCenter(receivedSummary);
            }
            receivedSummary.SaveWeightedAverageLog(userID);
        }
        /// <summary>
        /// Saves the price.
        /// </summary>
        /// <param name="rs">The rs.</param>
        /// <param name="userID">The user ID.</param>
        public void SavePrice(ReceivedSummary rs, int userID)
        {
            FlushData();
            if (BLL.Settings.SkipBeginningBalancePricing)
            {
                SetPricePerPackCostAndSellingPrice(rs);
                SendToFinanceManagerConfirmation(rs, userID);
            }
            else

                SetCostAndSellingPriceAndSendToConfirmation(rs, userID);

            if (!BLL.Settings.IsCenter)
            {
                PricePicklistforHub(rs);
                PriceDeliveryNoteforHub(rs);
            }
            else
            {
                PricePicklistforCenter(rs);
                PriceDeliveryNoteforCenter(rs);
            }
            rs.SaveWeightedAverageLog(userID);
        }
        /// <summary>
        /// Prices the picklistfor hub.
        /// </summary>
        /// <param name="rs">The rs.</param>
        public void PricePicklistforHub(ReceivedSummary rs)
        {
            string query = "";

            query = HCMIS.Repository.Queries.ReceiveDoc.UpdatePricePicklistforHub(rs.ItemID, rs.NewSellingPrice, BLL.Settings.NoOfDigitsAfterTheDecimalPoint, rs.SupplierID, rs.StoreID, rs.ManufacturerID, rs.UnitID, OrderStatus.Constant.ISSUED);
            LoadFromRawSql(query);
        }
        /// <summary>
        /// Prices the delivery notefor hub.
        /// </summary>
        /// <param name="rs">The rs.</param>
        public void PriceDeliveryNoteforHub(ReceivedSummary rs)
        {
            string query = "";
            query = HCMIS.Repository.Queries.ReceiveDoc.UpdatePriceDeliveryNoteforHub(rs.ItemID, rs.SupplierID, rs.StoreID, rs.ManufacturerID, rs.UnitID, rs.NewSellingPrice, BLL.Settings.NoOfDigitsAfterTheDecimalPoint);
            LoadFromRawSql(query);

            query = HCMIS.Repository.Queries.ReceiveDoc.UpdatePriceDeliveryNoteforHub1(rs.ItemID, rs.SupplierID, rs.StoreID, rs.ManufacturerID, rs.UnitID, rs.NewSellingPrice, BLL.Settings.NoOfDigitsAfterTheDecimalPoint);

            //Fix the Items in the pick list for delivery notes. (That have already been issued but need to be reprinted)
            LoadFromRawSql(query);
            query = HCMIS.Repository.Queries.ReceiveDoc.UpdatePriceDeliveryNoteforHubPld(rs.ItemID, rs.SupplierID, rs.StoreID, rs.ManufacturerID, rs.UnitID, rs.NewSellingPrice, BLL.Settings.NoOfDigitsAfterTheDecimalPoint);
            LoadFromRawSql(query);
        }