public Tuple <bool, string, string> Post(DocumentStockReceiptList stockReceipt = null) { ManageDocumentReceipt documentReceipt = new ManageDocumentReceipt(); if (stockReceipt.Type == 2) { ManageSQLConnection manageSQLConnection = new ManageSQLConnection(); documentReceipt.GenerateReceipt(stockReceipt); //update print if (stockReceipt.UnLoadingSlip == "N" || string.IsNullOrEmpty(stockReceipt.UnLoadingSlip)) { List <KeyValuePair <string, string> > sqlParameters = new List <KeyValuePair <string, string> >(); sqlParameters.Add(new KeyValuePair <string, string>("@SRNo", stockReceipt.SRNo)); manageSQLConnection.UpdateValues("UpdateSRDetailsUnLoading", sqlParameters); } return(new Tuple <bool, string, string>(true, "Print Generated Sucessfully", "")); } else { ManageSQLConnection manageSQLConnection = new ManageSQLConnection(); List <KeyValuePair <string, string> > sqlParameters = new List <KeyValuePair <string, string> >(); sqlParameters.Add(new KeyValuePair <string, string>("@GCode", stockReceipt.ReceivingCode)); var result = manageSQLConnection.GetDataSetValues("AllowDocumentEntry", sqlParameters); ManageReport manageReport = new ManageReport(); if (manageReport.CheckDataAvailable(result)) { if (stockReceipt.SRNo.Trim() != "0" && stockReceipt.SRNo.Trim() != "-") { List <KeyValuePair <string, string> > sqlParameters1 = new List <KeyValuePair <string, string> >(); sqlParameters1.Add(new KeyValuePair <string, string>("@Type", "1")); sqlParameters1.Add(new KeyValuePair <string, string>("@DocNumber", stockReceipt.SRNo.Trim())); var result1 = manageSQLConnection.GetDataSetValues("CheckDocumentEdit", sqlParameters1); if (!manageReport.CheckDataAvailable(result1)) { return(new Tuple <bool, string, string>(false, GlobalVariable.DocumentEditPermission, "")); } // CheckDocumentEdit } else if (documentReceipt.CheckSRUpdateStatus(stockReceipt.SRNo)) { return(new Tuple <bool, string, string>(false, GlobalVariable.DocumentEditByHO, "")); } StockReceipt receipt = new StockReceipt(); return(receipt.InsertReceiptData(stockReceipt)); } else { return(new Tuple <bool, string, string>(false, "Permission not Granted", "")); } } }
public Tuple <bool, string, string> InsertReceiptSrDetailEntry(DocumentStockReceiptList receiptList) { SqlTransaction objTrans = null; string RowID = string.Empty, SRNo = string.Empty; bool isNewDoc = true; using (sqlConnection = new SqlConnection(GlobalVariable.ConnectionString)) { DataSet ds = new DataSet(); sqlCommand = new SqlCommand(); try { if (receiptList.SRNo.Length > 5) { isNewDoc = false; } if (sqlConnection.State == 0) { sqlConnection.Open(); } objTrans = sqlConnection.BeginTransaction(); sqlCommand.Transaction = objTrans; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "InsertSRDetails"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@SRDate", receiptList.SRDate); sqlCommand.Parameters.AddWithValue("@Trcode", receiptList.Trcode); sqlCommand.Parameters.AddWithValue("@Pallotment", receiptList.PAllotment); sqlCommand.Parameters.AddWithValue("@OrderNo", receiptList.OrderNo); sqlCommand.Parameters.AddWithValue("@OrderDate", receiptList.OrderDate); sqlCommand.Parameters.AddWithValue("@ReceivingCode", receiptList.ReceivingCode); sqlCommand.Parameters.AddWithValue("@IssuingCode", receiptList.DepositorCode); sqlCommand.Parameters.AddWithValue("@TruckMemoNo", receiptList.TruckMemoNo); sqlCommand.Parameters.AddWithValue("@TruckMemoDate", receiptList.TruckMemoDate); sqlCommand.Parameters.AddWithValue("@GServiceable", "0"); sqlCommand.Parameters.AddWithValue("@GUnserviceable", "0"); sqlCommand.Parameters.AddWithValue("@GPatches", "0"); sqlCommand.Parameters.AddWithValue("@RCode", receiptList.RCode); sqlCommand.Parameters.AddWithValue("@IssuerType", receiptList.DepositorType); sqlCommand.Parameters.AddWithValue("@ExportFlag", "N"); sqlCommand.Parameters.AddWithValue("@Unloadingslip", receiptList.UnLoadingSlip); sqlCommand.Parameters.AddWithValue("@Acknowledgementslip", "F"); sqlCommand.Parameters.AddWithValue("@Suspnstack", "-"); sqlCommand.Parameters.AddWithValue("@Suspnseaccno", "-"); sqlCommand.Parameters.AddWithValue("@Gunnyutilised", "0"); sqlCommand.Parameters.AddWithValue("@GunnyReleased", "0"); sqlCommand.Parameters.AddWithValue("@Flag1", "-"); sqlCommand.Parameters.AddWithValue("@Flag2", "-"); sqlCommand.Parameters.AddWithValue("@SRNo1", receiptList.SRNo); sqlCommand.Parameters.AddWithValue("@RowId1", receiptList.RowId); sqlCommand.Parameters.Add("@SRNo", SqlDbType.NVarChar, 13); sqlCommand.Parameters.Add("@RowId", SqlDbType.NVarChar, 30); sqlCommand.Parameters["@SRNo"].Direction = ParameterDirection.Output; sqlCommand.Parameters["@RowId"].Direction = ParameterDirection.Output; sqlCommand.ExecuteNonQuery(); RowID = (string)sqlCommand.Parameters["@RowId"].Value; SRNo = (string)sqlCommand.Parameters["@SRNO"].Value; //Generate the report file. receiptList.SRNo = SRNo; ManageDocumentReceipt documentReceipt = new ManageDocumentReceipt(); Task.Run(() => documentReceipt.GenerateReceipt(receiptList)); if (isNewDoc) { ManageIssuesAbstractPrint issuesAbstractPrint = new ManageIssuesAbstractPrint(); if (issuesAbstractPrint.GPSInsert(receiptList.Trcode)) // ACK only Transfer and Internal Transfer { ManageDataTransfer dataTransfer = new ManageDataTransfer(); DataTransferEntity transferEntity = new DataTransferEntity(); transferEntity.DocNumber = SRNo; transferEntity.DocDate = receiptList.SRDate; transferEntity.DocType = 1; transferEntity.TripType = 3; transferEntity.RCode = receiptList.RCode; transferEntity.GCode = receiptList.ReceivingCode; transferEntity.G2GStatus = 4; transferEntity.GPSStatus = 0; // dataTransfer.InsertDataTransfer(transferEntity); Task.Run(() => dataTransfer.InsertDataTransfer(transferEntity)); } } //Delete Sr Item Details sqlCommand.Parameters.Clear(); sqlCommand.Dispose(); sqlCommand = new SqlCommand(); sqlCommand.Transaction = objTrans; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "DeleteSRDetails"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@SRNo", SRNo); sqlCommand.ExecuteNonQuery(); ////Insert data into SR Item details List <StockReceiptItemList> stockReceiptItems = new List <StockReceiptItemList>(); stockReceiptItems = receiptList.ItemList; foreach (var item in stockReceiptItems) { sqlCommand.Parameters.Clear(); sqlCommand.Dispose(); sqlCommand = new SqlCommand(); sqlCommand.Transaction = objTrans; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "InsertSRItemDetails"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@RowId", RowID); sqlCommand.Parameters.AddWithValue("@SRNo", SRNo); sqlCommand.Parameters.AddWithValue("@TStockNo", item.TStockNo); sqlCommand.Parameters.AddWithValue("@ICode", item.ICode); sqlCommand.Parameters.AddWithValue("@IPCode", item.IPCode); sqlCommand.Parameters.AddWithValue("@NoPacking", item.NoPacking); sqlCommand.Parameters.AddWithValue("@WTCode", item.WTCode); sqlCommand.Parameters.AddWithValue("@GKgs", item.GKgs); sqlCommand.Parameters.AddWithValue("@Nkgs", item.Nkgs); sqlCommand.Parameters.AddWithValue("@Moisture", item.Moisture); sqlCommand.Parameters.AddWithValue("@Scheme", item.Scheme); sqlCommand.Parameters.AddWithValue("@RCode", receiptList.RCode); sqlCommand.Parameters.AddWithValue("@ExportFlag", "N"); sqlCommand.Parameters.AddWithValue("@flag1", item.StackYear); //sqlCommand.Parameters.AddWithValue("@Flag2", "-"); sqlCommand.ExecuteNonQuery(); } ////Insert SRT Details table sqlCommand.Parameters.Clear(); sqlCommand.Dispose(); sqlCommand = new SqlCommand(); sqlCommand.Transaction = objTrans; sqlCommand.Connection = sqlConnection; sqlCommand.CommandText = "InsertSRTDetails"; sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@RowId", RowID); sqlCommand.Parameters.AddWithValue("@SRNo", SRNo); sqlCommand.Parameters.AddWithValue("@Remarks", receiptList.Remarks); sqlCommand.Parameters.AddWithValue("@RCode", receiptList.RCode); sqlCommand.Parameters.AddWithValue("@LNo", receiptList.LNo); sqlCommand.Parameters.AddWithValue("@TransportMode", receiptList.MTransport); sqlCommand.Parameters.AddWithValue("@LFrom", receiptList.LFrom); sqlCommand.Parameters.AddWithValue("@TransporterName", receiptList.TransporterName); sqlCommand.Parameters.AddWithValue("@LWBillNo", receiptList.LWBNo); sqlCommand.Parameters.AddWithValue("@LWBillDate", receiptList.LWBDate); sqlCommand.Parameters.AddWithValue("@LDate", receiptList.LDate); sqlCommand.Parameters.AddWithValue("@ExportFlag", "N"); sqlCommand.ExecuteNonQuery(); objTrans.Commit(); return(new Tuple <bool, string, string>(true, GlobalVariable.SavedMessage + SRNo, SRNo)); } catch (Exception ex) { AuditLog.WriteError(ex.Message + " : " + ex.StackTrace); objTrans.Rollback(); return(new Tuple <bool, string, string>(false, GlobalVariable.ErrorMessage, "")); } finally { sqlConnection.Close(); sqlCommand.Dispose(); ds.Dispose(); dataAdapter = null; } } }