protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Pos_Transaction pos_Transaction = new Pos_Transaction();

        pos_Transaction = Pos_TransactionManager.GetPos_TransactionByID(Int32.Parse(Request.QueryString["pos_TransactionID"]));
        Pos_Transaction tempPos_Transaction = new Pos_Transaction();

        tempPos_Transaction.Pos_TransactionID = pos_Transaction.Pos_TransactionID;

        tempPos_Transaction.Pos_ProductID = Int32.Parse(ddlPos_Product.SelectedValue);
        tempPos_Transaction.Quantity      = Decimal.Parse(txtQuantity.Text);
        tempPos_Transaction.Pos_ProductTrasactionTypeID    = Int32.Parse(ddlPos_ProductTrasactionType.SelectedValue);
        tempPos_Transaction.Pos_ProductTransactionMasterID = Int32.Parse(ddlPos_ProductTransactionMaster.SelectedValue);
        tempPos_Transaction.WorkStationID = Int32.Parse(ddlWorkStation.SelectedValue);
        tempPos_Transaction.ExtraField1   = txtExtraField1.Text;
        tempPos_Transaction.ExtraField2   = txtExtraField2.Text;
        tempPos_Transaction.ExtraField3   = txtExtraField3.Text;
        tempPos_Transaction.ExtraField4   = txtExtraField4.Text;
        tempPos_Transaction.ExtraField5   = txtExtraField5.Text;
        tempPos_Transaction.AddedBy       = Int32.Parse(txtAddedBy.Text);
        tempPos_Transaction.AddedDate     = DateTime.Now;
        tempPos_Transaction.UpdatedBy     = Int32.Parse(txtUpdatedBy.Text);
        tempPos_Transaction.UpdatedDate   = txtUpdatedDate.Text;
        tempPos_Transaction.RowStatusID   = Int32.Parse(ddlRowStatus.SelectedValue);
        bool result = Pos_TransactionManager.UpdatePos_Transaction(tempPos_Transaction);

        Response.Redirect("AdminPos_TransactionDisplay.aspx");
    }
예제 #2
0
    protected void lbDelete_Click(object sender, EventArgs e)
    {
        LinkButton linkButton = new LinkButton();

        linkButton = (LinkButton)sender;
        bool result = Pos_TransactionManager.DeletePos_Transaction(Convert.ToInt32(linkButton.CommandArgument));

        showPos_TransactionGrid();
    }
    private void showPos_TransactionData()
    {
        Pos_Transaction pos_Transaction = new Pos_Transaction();

        pos_Transaction = Pos_TransactionManager.GetPos_TransactionByID(Int32.Parse(Request.QueryString["pos_TransactionID"]));

        ddlPos_Product.SelectedValue = pos_Transaction.Pos_ProductID.ToString();
        txtQuantity.Text             = pos_Transaction.Quantity.ToString();
        ddlPos_ProductTrasactionType.SelectedValue    = pos_Transaction.Pos_ProductTrasactionTypeID.ToString();
        ddlPos_ProductTransactionMaster.SelectedValue = pos_Transaction.Pos_ProductTransactionMasterID.ToString();
        ddlWorkStation.SelectedValue = pos_Transaction.WorkStationID.ToString();
        txtExtraField1.Text          = pos_Transaction.ExtraField1;
        txtExtraField2.Text          = pos_Transaction.ExtraField2;
        txtExtraField3.Text          = pos_Transaction.ExtraField3;
        txtExtraField4.Text          = pos_Transaction.ExtraField4;
        txtExtraField5.Text          = pos_Transaction.ExtraField5;
        txtAddedBy.Text            = pos_Transaction.AddedBy.ToString();
        txtUpdatedBy.Text          = pos_Transaction.UpdatedBy.ToString();
        txtUpdatedDate.Text        = pos_Transaction.UpdatedDate;
        ddlRowStatus.SelectedValue = pos_Transaction.RowStatusID.ToString();
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Pos_Transaction pos_Transaction = new Pos_Transaction();

        pos_Transaction.Pos_ProductID = Int32.Parse(ddlPos_Product.SelectedValue);
        pos_Transaction.Quantity      = Decimal.Parse(txtQuantity.Text);
        pos_Transaction.Pos_ProductTrasactionTypeID    = Int32.Parse(ddlPos_ProductTrasactionType.SelectedValue);
        pos_Transaction.Pos_ProductTransactionMasterID = Int32.Parse(ddlPos_ProductTransactionMaster.SelectedValue);
        pos_Transaction.WorkStationID = Int32.Parse(ddlWorkStation.SelectedValue);
        pos_Transaction.ExtraField1   = txtExtraField1.Text;
        pos_Transaction.ExtraField2   = txtExtraField2.Text;
        pos_Transaction.ExtraField3   = txtExtraField3.Text;
        pos_Transaction.ExtraField4   = txtExtraField4.Text;
        pos_Transaction.ExtraField5   = txtExtraField5.Text;
        pos_Transaction.AddedBy       = Int32.Parse(txtAddedBy.Text);
        pos_Transaction.AddedDate     = DateTime.Now;
        pos_Transaction.UpdatedBy     = Int32.Parse(txtUpdatedBy.Text);
        pos_Transaction.UpdatedDate   = txtUpdatedDate.Text;
        pos_Transaction.RowStatusID   = Int32.Parse(ddlRowStatus.SelectedValue);
        int resutl = Pos_TransactionManager.InsertPos_Transaction(pos_Transaction);

        Response.Redirect("AdminPos_TransactionDisplay.aspx");
    }
예제 #5
0
 private void showPos_TransactionGrid()
 {
     gvPos_Transaction.DataSource = Pos_TransactionManager.GetAllPos_Transactions();
     gvPos_Transaction.DataBind();
 }
예제 #6
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        int transactionTypeID = int.Parse(Request.QueryString["TransactionTypeID"]);

        int TransactionMasterID = 0;

        bool   IsIssueReturn = false;
        bool   isTransferToanotherShowroom = false;
        bool   isAdjustment = false;
        string Pending      = "Pending";

        switch (transactionTypeID)
        {
        case 10:     //Issue Return
            IsIssueReturn = true;
            break;

        case 11:     //Transfer to another showroom
            isTransferToanotherShowroom = true;
            break;

        case 23:     //Adjustment +
            isAdjustment = true;
            Pending      = "";
            break;

        case 24:     //Adjustment +
            isAdjustment = true;
            Pending      = "";
            break;

        default:
            break;
        }

        if (txtOldTransactionID.Text != "")
        {
            if (txtOldTransactionID.Text != "0")
            {
                TransactionMasterID = int.Parse(GetTransactionMasterID());
            }
            else
            {
                TransactionMasterID = int.Parse(txtOldTransactionID.Text);
            }

            if (TransactionMasterID == 0)
            {
                showAlartMessage("Wrong old ID");
                return;
            }
        }
        else
        {
            Pos_TransactionMaster pos_TransactionMaster        = new Pos_TransactionMaster();
            Pos_TransactionMaster pos_TransactionMasterOposite = new Pos_TransactionMaster();

            pos_TransactionMaster.TransactionDate       = DateTime.Parse(txtDate.Text);
            pos_TransactionMaster.TransactionID         = 0;
            pos_TransactionMaster.Pos_TransactionTypeID = transactionTypeID;
            pos_TransactionMaster.ToOrFromID            = (isAdjustment?int.Parse(ddlWorkStationSearch.SelectedValue): int.Parse(ddlWorkStation.SelectedValue));
            pos_TransactionMaster.Record         = "";
            pos_TransactionMaster.Particulars    = "";
            pos_TransactionMaster.WorkSatationID = int.Parse(ddlWorkStationSearch.SelectedValue);
            pos_TransactionMaster.ExtraField1    = "";
            pos_TransactionMaster.ExtraField2    = "";
            pos_TransactionMaster.ExtraField3    = "";
            pos_TransactionMaster.ExtraField4    = "";
            pos_TransactionMaster.ExtraField5    = Pending;
            pos_TransactionMaster.AddedBy        = getLogin().LoginID;
            pos_TransactionMaster.AddedDate      = DateTime.Now;
            pos_TransactionMaster.UpdatedBy      = getLogin().LoginID;
            pos_TransactionMaster.UpdatedDate    = DateTime.Now;
            pos_TransactionMaster.RowStatusID    = 1;
            if (isTransferToanotherShowroom)
            {
                TransactionMasterID = Pos_TransactionMasterManager.InsertPos_TransactionMaster(pos_TransactionMaster, true);
            }
            else
            {
                TransactionMasterID = Pos_TransactionMasterManager.InsertPos_TransactionMaster(pos_TransactionMaster);
            }

            pos_TransactionMaster = Pos_TransactionMasterManager.GetPos_TransactionMasterByID(TransactionMasterID);

            txtOldTransactionID.Text = pos_TransactionMaster.TransactionID.ToString();
        }

        string sql = "Declare @Count int; ";

        foreach (GridViewRow gvr in gvPos_Product.Rows)
        {
            HiddenField hfPos_ProductID = (HiddenField)gvr.FindControl("hfPos_ProductID");
            TextBox     txtQty          = (TextBox)gvr.FindControl("txtQty");

            if (txtQty.Text == "")
            {
                continue;
            }
            if (decimal.Parse(txtQty.Text) == 0)
            {
                continue;
            }

            Pos_Transaction pos_Transaction = new Pos_Transaction();

            pos_Transaction.Pos_ProductID = Int32.Parse(hfPos_ProductID.Value);
            pos_Transaction.Quantity      = Decimal.Parse(txtQty.Text);
            pos_Transaction.Pos_ProductTrasactionTypeID    = transactionTypeID;
            pos_Transaction.Pos_ProductTransactionMasterID = TransactionMasterID;
            pos_Transaction.WorkStationID = Int32.Parse(ddlWorkStationSearch.SelectedValue);
            pos_Transaction.ExtraField1   = "";
            pos_Transaction.ExtraField2   = "";
            pos_Transaction.ExtraField3   = "";
            pos_Transaction.ExtraField4   = "";
            pos_Transaction.ExtraField5   = "";
            pos_Transaction.AddedBy       = getLogin().LoginID;
            pos_Transaction.AddedDate     = DateTime.Now;
            pos_Transaction.UpdatedBy     = getLogin().LoginID;
            pos_Transaction.UpdatedDate   = DateTime.Now;
            pos_Transaction.RowStatusID   = 1;

            if (isTransferToanotherShowroom)
            {
                Pos_TransactionManager.InsertPos_TransactionWithOpositeEntry(pos_Transaction);
            }
            else
            {
                Pos_TransactionManager.InsertPos_Transaction(pos_Transaction);
            }



            if (IsIssueReturn)
            {
                Pos_TransactionType transactionType = Pos_TransactionTypeManager.GetPos_TransactionTypeByID(transactionTypeID);

                if (transactionType.CentralStockFormula != "0")
                {
                    //sql += "Update Pos_Product set ExtraField1 =(cast(ExtraField1 as decimal(10,2)) + ((" + transactionType.CentralStockFormula + ")*" + txtQty.Text + ")) where Pos_ProductID=" + pos_Transaction.Pos_ProductID.ToString() + ";";
                }

                if (transactionType.ShowRoomFormula != "0")
                {
                    sql += @"
                            set @Count=
                            (
                            select COUNT(*) from Pos_WorkStationStock
                            where ProductID=" + pos_Transaction.Pos_ProductID.ToString() + @" and WorkStationID=" + ddlWorkStationSearch.SelectedValue + @"
                            )

                            if @Count = 0
                            BEGIN
	                            INSERT INTO [Pos_WorkStationStock]
                                       ([WorkStationID]
                                       ,[ProductID]
                                       ,[Stock])
                                       VALUES(" + ddlWorkStationSearch.SelectedValue + @"," + pos_Transaction.Pos_ProductID.ToString() + @"," + txtQty.Text + @");
                            END
                            ELSE
                            BEGIN
                                Update Pos_WorkStationStock set Stock += ((" + transactionType.ShowRoomFormula + @")*" + txtQty.Text + @") where  WorkStationID=" + ddlWorkStationSearch.SelectedValue + @" and ProductID=" + pos_Transaction.Pos_ProductID.ToString() + @";
                            END;";
                }
            }

            if (isTransferToanotherShowroom)
            {
                Pos_TransactionType transactionType = Pos_TransactionTypeManager.GetPos_TransactionTypeByID(transactionTypeID);

                if (transactionType.ShowRoomFormula != "0")
                {
                    sql += @"/*
                            set @Count=
                            (
                            select COUNT(*) from Pos_WorkStationStock
                            where ProductID=" + pos_Transaction.Pos_ProductID.ToString() + @" and WorkStationID=" + ddlWorkStationSearch.SelectedValue + @"
                            )

                            if @Count = 0
                            BEGIN
	                            INSERT INTO [Pos_WorkStationStock]
                                       ([WorkStationID]
                                       ,[ProductID]
                                       ,[Stock])
                                       VALUES(" + ddlWorkStationSearch.SelectedValue + @"," + pos_Transaction.Pos_ProductID.ToString() + @"," + txtQty.Text + @");
                            END
                            ELSE
                            BEGIN
                                Update Pos_WorkStationStock set Stock += ((+1)*" + txtQty.Text + @") where  WorkStationID=" + ddlWorkStationSearch.SelectedValue + @" and  ProductID=" + pos_Transaction.Pos_ProductID.ToString() + @";
                            END;
                            */
                                Update Pos_WorkStationStock set Stock += ((-1)*" + txtQty.Text + @") where WorkStationID=" + ddlWorkStationSearch.SelectedValue + @" and  ProductID=" + pos_Transaction.Pos_ProductID.ToString() + @";

                            ";
                }
            }

            if (isAdjustment)
            {
                Pos_TransactionType transactionType = Pos_TransactionTypeManager.GetPos_TransactionTypeByID(transactionTypeID);

                if (transactionType.ShowRoomFormula != "0")
                {
                    sql += @"
                            set @Count=
                            (
                            select COUNT(*) from Pos_WorkStationStock
                            where ProductID=" + pos_Transaction.Pos_ProductID.ToString() + @" and WorkStationID=" + ddlWorkStationSearch.SelectedValue + @"
                            )

                            if @Count = 0
                            BEGIN
	                            INSERT INTO [Pos_WorkStationStock]
                                       ([WorkStationID]
                                       ,[ProductID]
                                       ,[Stock])
                                       VALUES(" + ddlWorkStationSearch.SelectedValue + @"," + pos_Transaction.Pos_ProductID.ToString() + @"," + txtQty.Text + @");
                            END
                            ELSE
                            BEGIN
                                Update Pos_WorkStationStock set Stock += ((" + (transactionTypeID == 23?"":"-") + @"1)*" + txtQty.Text + @") where  WorkStationID=" + ddlWorkStationSearch.SelectedValue + @" and  ProductID=" + pos_Transaction.Pos_ProductID.ToString() + @";
                            END;
                            ";
                }
            }
        }

        CommonManager.SQLExec(sql);
        btnSearch_Click(this, new EventArgs());
        hlnkProductionPrint.Visible     = true;
        hlnkProductionPrint.NavigateUrl = "TransactionPrint.aspx?Pos_TransactionMasterID=" + TransactionMasterID.ToString();
        doSearch(true);
    }
예제 #7
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (ddlWorkStation.SelectedValue == "0")
        {
            showAlartMessage("Please select the Work Station");
            return;
        }
        if (Request.QueryString["TransactionTypeID"] == "15")
        {
            ddlWorkStation.SelectedValue = "1";
            if (ddlRefference.SelectedValue == "0")
            {
                showAlartMessage("Please select the Work Station or Ref");
                return;
            }
        }
        if (gvPos_Product.Rows.Count == 0)
        {
            showAlartMessage("Plz add some product");
            return;
        }
        foreach (GridViewRow gvr in gvPos_Product.Rows)
        {
            Label   lblBarCode = (Label)gvr.FindControl("lblBarCode");
            TextBox txtQty     = (TextBox)gvr.FindControl("txtQty");
            Label   lblStock   = (Label)gvr.FindControl("lblStock");

            if (decimal.Parse(lblStock.Text) < decimal.Parse(txtQty.Text))
            {
                showAlartMessage(lblBarCode.Text + " is going to issue more than stock. pleae enter the correct value");
                return;
            }
        }
        btnSubmit.Visible = false;

        int transactionTypeID = int.Parse(Request.QueryString["TransactionTypeID"]);

        int TransactionMasterID = 0;

        if (txtOldTransactionID.Text != "")
        {
            if (txtOldTransactionID.Text != "0")
            {
                TransactionMasterID = int.Parse(GetTransactionMasterID());
            }
            else
            {
                TransactionMasterID = int.Parse(txtOldTransactionID.Text);
            }

            if (TransactionMasterID == 0)
            {
                showAlartMessage("Wrong old ID");
                return;
            }
        }
        else
        {
            Pos_TransactionMaster pos_TransactionMaster = new Pos_TransactionMaster();

            pos_TransactionMaster.TransactionDate       = DateTime.Parse(txtDate.Text);
            pos_TransactionMaster.TransactionID         = 0;
            pos_TransactionMaster.Pos_TransactionTypeID = transactionTypeID;
            pos_TransactionMaster.ToOrFromID            = int.Parse(ddlWorkStation.SelectedValue);
            pos_TransactionMaster.Record         = "";
            pos_TransactionMaster.Particulars    = "";
            pos_TransactionMaster.WorkSatationID = 1;
            pos_TransactionMaster.ExtraField1    = "";
            pos_TransactionMaster.ExtraField2    = "";
            pos_TransactionMaster.ExtraField3    = "";
            pos_TransactionMaster.ExtraField4    = "";
            pos_TransactionMaster.ExtraField5    = (transactionTypeID == 9? "Pending":"");
            pos_TransactionMaster.AddedBy        = getLogin().LoginID;
            pos_TransactionMaster.AddedDate      = DateTime.Now;
            pos_TransactionMaster.UpdatedBy      = getLogin().LoginID;
            pos_TransactionMaster.UpdatedDate    = DateTime.Now;
            pos_TransactionMaster.RowStatusID    = 1;
            TransactionMasterID   = Pos_TransactionMasterManager.InsertPos_TransactionMaster(pos_TransactionMaster);
            pos_TransactionMaster = Pos_TransactionMasterManager.GetPos_TransactionMasterByID(TransactionMasterID);

            txtOldTransactionID.Text = pos_TransactionMaster.TransactionID.ToString();
        }

        string sql = "Declare @Count int; ";

        foreach (GridViewRow gvr in gvPos_Product.Rows)
        {
            HiddenField hfPos_ProductID = (HiddenField)gvr.FindControl("hfPos_ProductID");
            TextBox     txtQty          = (TextBox)gvr.FindControl("txtQty");
            Label       lblStock        = (Label)gvr.FindControl("lblStock");

            if (txtQty.Text == "")
            {
                continue;
            }
            if (decimal.Parse(txtQty.Text) == 0)
            {
                continue;
            }
            if (decimal.Parse(lblStock.Text) < decimal.Parse(txtQty.Text))
            {
                txtQty.Text = lblStock.Text;
            }

            Pos_Transaction pos_Transaction = new Pos_Transaction();

            pos_Transaction.Pos_ProductID = Int32.Parse(hfPos_ProductID.Value);
            pos_Transaction.Quantity      = Decimal.Parse(txtQty.Text);
            pos_Transaction.Pos_ProductTrasactionTypeID    = transactionTypeID;
            pos_Transaction.Pos_ProductTransactionMasterID = TransactionMasterID;
            pos_Transaction.WorkStationID = Int32.Parse(ddlWorkStation.SelectedValue);
            pos_Transaction.ExtraField1   = "";
            pos_Transaction.ExtraField2   = "";
            pos_Transaction.ExtraField3   = "";
            pos_Transaction.ExtraField4   = "";
            pos_Transaction.ExtraField5   = "";
            pos_Transaction.AddedBy       = getLogin().LoginID;
            pos_Transaction.AddedDate     = DateTime.Now;
            pos_Transaction.UpdatedBy     = getLogin().LoginID;
            pos_Transaction.UpdatedDate   = DateTime.Now;
            pos_Transaction.RowStatusID   = 1;
            int resutl = Pos_TransactionManager.InsertPos_Transaction(pos_Transaction);


            bool IsGeneralOperation = false;
            //accounts need to update
            switch (transactionTypeID)
            {
            case 9:     //Issue
                IsGeneralOperation = true;
                break;

            case 5:     //Adjustment -
                IsGeneralOperation = true;
                break;

            case 6:     //Adjustment +
                IsGeneralOperation = true;
                break;

            default:
                break;
            }

            if (IsGeneralOperation)
            {
                Pos_TransactionType transactionType = Pos_TransactionTypeManager.GetPos_TransactionTypeByID(transactionTypeID);

                if (transactionType.CentralStockFormula != "0")
                {
                    sql += "Update Pos_Product set ExtraField1 =(cast(ExtraField1 as decimal(10,2)) + ((" + transactionType.CentralStockFormula + ")*" + txtQty.Text + ")) where Pos_ProductID=" + pos_Transaction.Pos_ProductID.ToString() + ";";
                }

                /*
                 * Any thing will be send to another place need the accepting from the receiver
                 * if (transactionType.ShowRoomFormula != "0")
                 * {
                 *  sql += @"
                 *          set @Count=
                 *          (
                 *          select COUNT(*) from Pos_WorkStationStock
                 *          where ProductID=" + pos_Transaction.Pos_ProductID.ToString() + @" and WorkStationID="+ddlWorkStation.SelectedValue+@"
                 *          )
                 *
                 *          if @Count = 0
                 *          BEGIN
                 *                  INSERT INTO [Pos_WorkStationStock]
                 *                     ([WorkStationID]
                 *                     ,[ProductID]
                 *                     ,[Stock])
                 *                     VALUES(" + ddlWorkStation.SelectedValue + @"," + pos_Transaction.Pos_ProductID.ToString() + @"," + txtQty.Text + @");
                 *          END
                 *          ELSE
                 *          BEGIN
                 *              Update Pos_WorkStationStock set Stock += ((" + transactionType.ShowRoomFormula + @")*" + txtQty.Text + @") where ProductID=" + pos_Transaction.Pos_ProductID.ToString() + @";
                 *          END;";
                 * }
                 */
            }
        }

        saveForRemoteDatabase(TransactionMasterID);

        CommonManager.SQLExec(sql);
        btnSearch_Click(this, new EventArgs());
        hlnkProductionPrint.Visible     = true;
        hlnkProductionPrint.NavigateUrl = (Request.QueryString["TransactionTypeID"] == "9" ? "DelivaryChalanPrint" : "TransactionPrint") + ".aspx?Pos_TransactionMasterID=" + TransactionMasterID.ToString();
    }