private void btnFixLocationStuff_Click(object sender, EventArgs e)
        {
            int storeID = Convert.ToInt32(lkStoreLocation.EditValue);

            BLL.ReceiveDoc rd = new BLL.ReceiveDoc();
            rd.LoadReceivesForStores(storeID);
            while (!rd.EOF)
            {
                BLL.ReceivePallet rp = new BLL.ReceivePallet();
                rp.LoadByReceiveDocID(rd.ID);
                decimal receivedQuantity = 0, balance = 0;
                if (rp.RowCount == 1)// rp.RowCount > 0)
                {
                    while (!rp.EOF)
                    {
                        receivedQuantity += rp.IsColumnNull("ReceivedQuantity") ? 0 : rp.ReceivedQuantity;
                        balance          += rp.IsColumnNull("Balance") ? 0 : rp.Balance;
                        rp.MoveNext();
                    }
                    rp.Rewind();

                    while (!rp.EOF && rp.IsColumnNull("ReceivedQuantity"))
                    {
                        rp.MoveNext();
                    }

                    if (rd.Quantity != receivedQuantity && rd.Quantity > receivedQuantity)
                    {
                        rp.ReceivedQuantity += (rd.Quantity - receivedQuantity);
                    }
                    if (rd.QuantityLeft != balance && rd.QuantityLeft > 0)//rd.QuantityLeft > balance)
                    {
                        rp.Balance += (rd.QuantityLeft - balance);
                    }
                    rp.Save();
                }
                rd.MoveNext();
            }
            XtraMessageBox.Show("Completed!");
        }
        private void btnFixLocationStuff_Click(object sender, EventArgs e)
        {
            int storeID = Convert.ToInt32(lkStoreLocation.EditValue);
            BLL.ReceiveDoc rd = new BLL.ReceiveDoc();
            rd.LoadReceivesForStores(storeID);
            while(!rd.EOF)
            {
                BLL.ReceivePallet rp = new BLL.ReceivePallet();
                rp.LoadByReceiveDocID(rd.ID);
                decimal receivedQuantity = 0, balance = 0;
                if (rp.RowCount==1)// rp.RowCount > 0)
                {
                    while (!rp.EOF)
                    {
                        receivedQuantity += rp.IsColumnNull("ReceivedQuantity") ? 0 : rp.ReceivedQuantity;
                        balance += rp.IsColumnNull("Balance") ? 0 : rp.Balance;
                        rp.MoveNext();
                    }
                    rp.Rewind();

                    while (!rp.EOF && rp.IsColumnNull("ReceivedQuantity"))
                    {
                        rp.MoveNext();
                    }

                    if (rd.Quantity != receivedQuantity && rd.Quantity > receivedQuantity)
                    {
                        rp.ReceivedQuantity += (rd.Quantity - receivedQuantity);
                    }
                    if (rd.QuantityLeft != balance && rd.QuantityLeft > 0)//rd.QuantityLeft > balance)
                    {
                        rp.Balance += (rd.QuantityLeft - balance);
                    }
                    rp.Save();
                }
                rd.MoveNext();
            }
            XtraMessageBox.Show("Completed!");
        }