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"); }
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); }
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(); }