Пример #1
0
        protected void GetPurchaseReturnProductListById(string ReturnId)
        {
            PurchaseReturnBLL purchaseReturn = new PurchaseReturnBLL();

            try
            {
                DataTable dt = purchaseReturn.GetPurchaseReturnProductListById(ReturnId);

                if (dt.Rows.Count > 0)
                {
                    salesReturnProductListGridView.DataSource = dt;
                    salesReturnProductListGridView.DataBind();

                    if (salesReturnProductListGridView.Rows.Count > 0)
                    {
                        salesReturnProductListGridView.UseAccessibleHeader = true;
                        salesReturnProductListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                    }
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                purchaseReturn = null;
            }
        }
Пример #2
0
        protected void GetPurchaseReturnById(string ReturnId)
        {
            PurchaseReturnBLL purchaseReturn = new PurchaseReturnBLL();

            try
            {
                DataTable dt = purchaseReturn.GetPurchaseReturnById(ReturnId);

                if (dt.Rows.Count > 0)
                {
                    returnIdLabel.Text = dt.Rows[0]["PurchaseReturnId"].ToString();
                    returnDateLabel.Text = dt.Rows[0]["ReturnDate"].ToString();
                    VendorIdLabel.Text = dt.Rows[0]["VendorId"].ToString() + " " + dt.Rows[0]["VendorName"].ToString();
                    returnAmountLabel.Text = dt.Rows[0]["ReturnAmount"].ToString();
                  //  returnVATAmountLabel.Text = dt.Rows[0]["ReturnVATAmount"].ToString();
                    dueAmountLabel.Text = dt.Rows[0]["PurchaseDueAmount"].ToString();
                    statusLabel.Text = dt.Rows[0]["Status"].ToString();
                    salesCenterIdLabel.Text = dt.Rows[0]["CenterId"].ToString();
                    salesCenterNameLabel.Text = dt.Rows[0]["CenterName"].ToString();
                    AdjustedAmountLabel.Text = dt.Rows[0]["AdjustedAmount"].ToString();
                    SalesPersonLabel.Text = dt.Rows[0]["CreatedBy"].ToString();

                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                purchaseReturn = null;
            }
        }
Пример #3
0
        protected void SavePurchesReturn(string isDuesAdjust)
        {
            PurchaseReturnBLL purchaseReturn = new PurchaseReturnBLL();

            try
            {
                if (Convert.ToDecimal(totalReturnAmountTextBox.Text) > 0)
                {
                    DataTable dtPrdList = (DataTable)LumexSessionManager.Get("RPLdt");

                    for (int i = 0; i < purchesRecordProductListGridView.Rows.Count; i++)
                    {
                        TextBox returnQuantityTextBox =
                            (TextBox)purchesRecordProductListGridView.Rows[i].FindControl("returnQuantityTextBox");
                        dtPrdList.Rows[i]["ReturnQuantity"] = returnQuantityTextBox.Text.Trim();

                        TextBox returnAmountTextBox =
                            (TextBox)purchesRecordProductListGridView.Rows[i].FindControl("returnAmountTextBox");
                        dtPrdList.Rows[i]["ReturnAmount"] = returnAmountTextBox.Text.Trim();
                    }
                    dtPrdList.AcceptChanges();
                    for (int i = 0; i < dtPrdList.Rows.Count; i++)
                    {
                        if (string.IsNullOrEmpty(dtPrdList.Rows[i]["ReturnQuantity"].ToString()) ||
                            dtPrdList.Rows[i]["ReturnQuantity"].ToString() == "0")
                        {
                            dtPrdList.Rows.RemoveAt(i);
                            i--;
                        }
                    }

                    purchaseReturn.PurchaseRecordId = idLabel.Text.Trim();
                    purchaseReturn.SalesCenterId = salesCenterIdLabel.Text.Trim();
                    purchaseReturn.ReturnAmount = totalReturnAmountTextBox.Text.Trim();
                    purchaseReturn.ReturnVATAmount = totalReturnVATAmountTextBox.Text.Trim();
                    purchaseReturn.dueAmount = salesDueAmountTextBox.Text.Trim();
                    purchaseReturn.VendorId = VendorIdLabel.Text.Trim();
                    purchaseReturn.IsDuesAdjustforSalesReturn = isDuesAdjust;

                    DataTable dt = purchaseReturn.SavePurchesReturn(dtPrdList);

                    if (isDuesAdjust == "Y")
                    {

                        LumexSessionManager.Add("ReturnableAmount", dt.Rows[0]["ReturnAmount"]);
                        string message =
                            "Purchase <span class='actionTopic'>Return</span> Successfully with Adjust Dues of Return ID: <span class='actionTopic'>" +
                            dt.Rows[0]["PurchaseReturnId"] + " And get Money Back Amount:" + dt.Rows[0]["ReturnAmount"] +
                            "</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; SuccessAlert(\"" +
                            "Process Succeed" + "\", \"" + message + "\", \"\");");

                    }
                    else
                    {
                        string message =
                            "Purchase <span class='actionTopic'>Return</span> Successfully with Money Back Only of Return ID: <span class='actionTopic'>" +
                            dt.Rows[0]["PurchaseReturnId"] + " And get Money Back Amount:" + dt.Rows[0]["ReturnAmount"] +
                            "</span>.";
                        MyAlertBox(
                            "var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/SalesReturn/SalesReturnList.aspx\"; }; SuccessAlert(\"" +
                            "Process Succeed" + "\", \"" + message + "\", \"\");");

                    }
                    receiveSalesReturnforAdjustButton.Enabled = false;
                    receiveSalesReturnForMoneyBackButton.Enabled = false;
                }
                else
                {
                    string message = "Sales Return Amount must be greater than 0.00";

                    MyAlertBox("WarningAlert(  \"" + message + "\", \"\");");
                }
            }
            catch (Exception ex)
            {
                string message = "Some things goes wrong on create Sales Return";
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(  \"" + message + "\", \"\");");
            }
            finally
            {
                purchaseReturn = null;
            }
        }
Пример #4
0
        //protected void purchaseReturnFormDropdownList_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        if (purchaseReturnFormDropdownList.SelectedValue == "WH")
        //        {
        //            LoadWarehouse();
        //            wareHouseorSCLabel.Text = "Warehouse";
        //        }
        //        else
        //        {
        //            LoadSalesCenters();
        //            wareHouseorSCLabel.Text = "Sales Center";
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        string message = ex.Message;
        //        if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
        //        MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
        //    }
        //}
        protected void recordListButton_Click(object sender, EventArgs e)
        {
            PurchaseReturnBLL purchaseReturn = new PurchaseReturnBLL();

            try
            {
                if (salesCenterDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Sales Center Name field is required.";
                }
                else if (fromDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim()) == "False")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Date From field is required.";
                }
                else if (toDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim()) == "False")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Date To field is required.";
                }
                else
                {
                    string CenterId = salesCenterDropDownList.SelectedValue.Trim();
                    string fromDate = LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim());
                    string toDate = LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim());
                    string status = statusDropDownList.SelectedValue.Trim();

                    DataTable dt = purchaseReturn.GetPurchaseReturnsListBySalesCenterDateRangeAndStatus(CenterId, fromDate, toDate, status);

                    PurchaseReturnListGridView.DataSource = dt;
                    PurchaseReturnListGridView.DataBind();

                    if (PurchaseReturnListGridView.Rows.Count > 0)
                    {
                        PurchaseReturnListGridView.UseAccessibleHeader = true;
                        PurchaseReturnListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                    }
                    else
                    {
                        msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                purchaseReturn = null;
            }

        }
Пример #5
0
        internal DataTable SavePurchesReturn(PurchaseReturnBLL purchaseReturnBLL, DataTable dtPrdList, LumexDBPlayer db)
        {
            string purchesReturnId = "";

            try
            {
                db.AddParameters("@RecordId", purchaseReturnBLL.PurchaseRecordId.Trim());
                db.AddParameters("@ReturnAmount", purchaseReturnBLL.ReturnAmount.Trim());
                db.AddParameters("@CenterId", purchaseReturnBLL.SalesCenterId.Trim());
                db.AddParameters("@DueAmount", purchaseReturnBLL.dueAmount.Trim());
                db.AddParameters("@CreatedBy", LumexSessionManager.Get("ActiveUserId").ToString());
                db.AddParameters("@CreatedFrom", LumexLibraryManager.GetTerminal());

                DataTable dt = db.ExecuteDataTable("[INSERT_PURCHASE_RETURN_RECORD]", true);

                if (dt.Rows.Count > 0)
                {
                    purchesReturnId = dt.Rows[0][0].ToString();
                }

                for (int i = 0; i < dtPrdList.Rows.Count; i++)
                {
                     
                    db.ClearParameters();
                    db.AddParameters("@PurchaseRecordId", purchaseReturnBLL.PurchaseRecordId);
                    db.AddParameters("@ReturnId", purchesReturnId.ToString());
                    db.AddParameters("@ProductId", dtPrdList.Rows[i]["ProductId"].ToString());
                    db.AddParameters("@PurchaseRate", dtPrdList.Rows[i]["RatePerUnit"].ToString());
                    db.AddParameters("@RatePerUnit", dtPrdList.Rows[i]["RatePerUnit"].ToString());
                    db.AddParameters("@ReturnQuantity", dtPrdList.Rows[i]["ReturnQuantity"].ToString());
                    db.AddParameters("@ReturnAmount", dtPrdList.Rows[i]["ReturnAmount"].ToString());
                   // db.AddParameters("@VATPercentage", dtPrdList.Rows[i]["VATPercentage"].ToString());

                    db.ExecuteNonQuery("[INSERT_PURCHASE_RETURN_RECORD_PRODUCT]", true);
                }

                db.ClearParameters();
                db.AddParameters("@CenterId", purchaseReturnBLL.SalesCenterId.Trim());
                db.AddParameters("@ReturnId", purchesReturnId.Trim());
                db.AddParameters("@ModifiedBy", LumexSessionManager.Get("ActiveUserId").ToString());
                db.AddParameters("@ModifiedFrom", LumexLibraryManager.GetTerminal());

                db.ExecuteNonQuery("[UPDATE_PRODUCT_STOCK_FOR_PURCHASE_RETURN]", true);

                db.ClearParameters();
              
                db.AddParameters("@PurchaseRecordId", purchaseReturnBLL.PurchaseRecordId.Trim());
                db.AddParameters("@CenterId", purchaseReturnBLL.SalesCenterId.Trim());
                db.AddParameters("@ReturnId", purchesReturnId.Trim());
                db.AddParameters("@DueAmount", purchaseReturnBLL.dueAmount.Trim());
                db.AddParameters("@ReturnAmount", purchaseReturnBLL.ReturnAmount.Trim());
                db.AddParameters("@VendorId", purchaseReturnBLL.VendorId.Trim());
                db.AddParameters("@IsDueAdjust", purchaseReturnBLL.IsDuesAdjustforSalesReturn);
                db.AddParameters("@CreatedBy", LumexSessionManager.Get("ActiveUserId").ToString());
                db.AddParameters("@CreatedFrom", LumexLibraryManager.GetTerminal());

                dt = db.ExecuteDataTable("[INSERT_PURCHASE_RETURN_RECEIVE_PAYMENT_LEDGER_TRANSACTION]", true);

                return dt;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                purchaseReturnBLL = null;
                dtPrdList = null;
            }
        }