Esempio n. 1
0
        public bool InsertOpeningBalanceMaster(OpeningBalanceEntity openingBalanceList)
        {
            // string Rowid = string.Empty;
            using (sqlConnection = new SqlConnection(GlobalVariable.ConnectionString))
            {
                DataSet ds = new DataSet();
                sqlCommand = new SqlCommand();
                try
                {
                    if (sqlConnection.State == 0)
                    {
                        sqlConnection.Open();
                    }
                    sqlCommand.Connection  = sqlConnection;
                    sqlCommand.CommandText = "InsertOpeningBalanceMaster";
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    sqlCommand.Parameters.AddWithValue("@GodownCode", openingBalanceList.GodownCode);
                    sqlCommand.Parameters.AddWithValue("@RegionCode", openingBalanceList.RegionCode);
                    sqlCommand.Parameters.AddWithValue("@CommodityCode", openingBalanceList.CommodityCode);
                    sqlCommand.Parameters.AddWithValue("@BookBalanceBags", openingBalanceList.BookBalanceBags);
                    sqlCommand.Parameters.AddWithValue("@BookBalanceWeight", openingBalanceList.BookBalanceWeight);
                    sqlCommand.Parameters.AddWithValue("@PhysicalBalanceBags", openingBalanceList.PhysicalBalanceBags);
                    sqlCommand.Parameters.AddWithValue("@PhysicalBalanceWeight", openingBalanceList.PhysicalBalanceWeight);
                    sqlCommand.Parameters.AddWithValue("@CumulitiveShortage", openingBalanceList.CumulitiveShortage);
                    sqlCommand.Parameters.AddWithValue("@ObDate", openingBalanceList.ObDate);
                    sqlCommand.Parameters.AddWithValue("@PurchaseRate", "0");
                    //  sqlCommand.Parameters.AddWithValue("@CurYear", "0");
                    sqlCommand.Parameters.AddWithValue("@ExportFlag", "N");
                    sqlCommand.Parameters.AddWithValue("@Excess", "0");
                    sqlCommand.Parameters.AddWithValue("@Flag1", "");
                    sqlCommand.Parameters.AddWithValue("@Flag2", "-");
                    sqlCommand.Parameters.AddWithValue("@Receipts", "0.0");
                    sqlCommand.Parameters.AddWithValue("@Issues", "0.0");
                    sqlCommand.Parameters.AddWithValue("@TransferIn", "0.0");
                    sqlCommand.Parameters.AddWithValue("@TransferOut", "0.0");
                    sqlCommand.Parameters.AddWithValue("@WriteOff", "0.0");
                    sqlCommand.Parameters.AddWithValue("@ExcessReceipt", "0.0");
                    sqlCommand.Parameters.AddWithValue("@Others", "0.0");
                    sqlCommand.Parameters.AddWithValue("@Balance", "0");
                    //sqlCommand.Parameters.Add("@Rowid", SqlDbType.NVarChar, 26);
                    //sqlCommand.Parameters["@Rowid"].Direction = ParameterDirection.Output;
                    sqlCommand.ExecuteNonQuery();

                    //  Rowid = (string)sqlCommand.Parameters["@Rowid"].Value;

                    sqlCommand.Parameters.Clear();
                    sqlCommand.Dispose();
                    //   objTrans.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    AuditLog.WriteError(ex.Message + " : " + ex.StackTrace);
                    return(false);
                }
                finally
                {
                    if (sqlConnection.State == 0)
                    {
                        sqlConnection.Open();
                    }
                    sqlCommand.Dispose();
                    ds.Dispose();
                    dataAdapter = null;
                }
            }
        }
Esempio n. 2
0
        public Tuple <bool, string, string> InsertIssuesEntry(DocumentStockIssuesEntity issueList)
        {
            SqlTransaction objTrans = null;
            string         RowID = string.Empty, SINo = string.Empty;
            bool           isNewDoc = true;

            using (sqlConnection = new SqlConnection(GlobalVariable.ConnectionString))
            {
                DataSet ds = new DataSet();

                sqlCommand = new SqlCommand();
                try
                {
                    if (issueList.DocType == 2)
                    {
                        isNewDoc = false;
                    }
                    if (sqlConnection.State == 0)
                    {
                        sqlConnection.Open();
                    }
                    objTrans = sqlConnection.BeginTransaction();
                    sqlCommand.Transaction = objTrans;
                    sqlCommand.Connection  = sqlConnection;
                    sqlCommand.CommandText = "InsertStockIssueDetails";
                    sqlCommand.CommandType = CommandType.StoredProcedure;
                    sqlCommand.Parameters.AddWithValue("@SIDate", issueList.SIDate);
                    sqlCommand.Parameters.AddWithValue("@Trcode", issueList.Trcode);
                    sqlCommand.Parameters.AddWithValue("@IRelates", issueList.IRelates);
                    sqlCommand.Parameters.AddWithValue("@DNo", issueList.DNo);
                    sqlCommand.Parameters.AddWithValue("@DDate", issueList.DDate);
                    sqlCommand.Parameters.AddWithValue("@WCCode", issueList.WCCode);
                    sqlCommand.Parameters.AddWithValue("@IssuingCode", issueList.IssuingCode);
                    sqlCommand.Parameters.AddWithValue("@Receivorcode", issueList.Receivorcode);
                    sqlCommand.Parameters.AddWithValue("@issuetype1", issueList.Issuetype);
                    sqlCommand.Parameters.AddWithValue("@SoundServiceable", issueList.SoundServiceable);
                    sqlCommand.Parameters.AddWithValue("@ServiceablePatches", issueList.ServiceablePatches);
                    sqlCommand.Parameters.AddWithValue("@Gunnyutilised", issueList.GunnyUtilised);
                    sqlCommand.Parameters.AddWithValue("@GunnyReleased", issueList.GunnyReleased);
                    sqlCommand.Parameters.AddWithValue("@Remarks", issueList.Remarks);
                    sqlCommand.Parameters.AddWithValue("@TransporterName", issueList.TransporterName);
                    sqlCommand.Parameters.AddWithValue("@TransportingCharge", issueList.TransportingCharge);
                    sqlCommand.Parameters.AddWithValue("@LorryNo", issueList.LorryNo);
                    sqlCommand.Parameters.AddWithValue("@NewBale", issueList.NewBale);
                    sqlCommand.Parameters.AddWithValue("@RCode", issueList.RCode);
                    sqlCommand.Parameters.AddWithValue("@IssueType", "-");
                    sqlCommand.Parameters.AddWithValue("@ExportFlag", "N");
                    sqlCommand.Parameters.AddWithValue("@Loadingslip", issueList.Loadingslip);
                    sqlCommand.Parameters.AddWithValue("@IssueMemo", "-");
                    sqlCommand.Parameters.AddWithValue("@Flag1", issueList.ManualDocNo);
                    sqlCommand.Parameters.AddWithValue("@Flag2", issueList.IssueRegularAdvance);
                    sqlCommand.Parameters.AddWithValue("@SINo1", issueList.SINo != null ? issueList.SINo : "");
                    sqlCommand.Parameters.AddWithValue("@RowId1", issueList.RowId != null ? issueList.RowId : "");
                    sqlCommand.Parameters.Add("@SINo", SqlDbType.NVarChar, 13);
                    sqlCommand.Parameters.Add("@RowId", SqlDbType.NVarChar, 30);
                    sqlCommand.Parameters["@SINo"].Direction  = ParameterDirection.Output;
                    sqlCommand.Parameters["@RowId"].Direction = ParameterDirection.Output;
                    sqlCommand.ExecuteNonQuery();

                    RowID          = Convert.ToString(sqlCommand.Parameters["@RowId"].Value);
                    SINo           = Convert.ToString(sqlCommand.Parameters["@SINo"].Value);
                    issueList.SINo = SINo;

                    //insert record into gatepass table
                    if (isNewDoc)
                    {
                        if (issueList.IssuingCode.Trim() != issueList.Receivorcode.Trim())
                        {
                            GatePassEntity gatePassEntity = new GatePassEntity
                            {
                                LorryNumber    = issueList.LorryNo,
                                DocumentTye    = 2,
                                GCode          = issueList.IssuingCode,
                                RCode          = issueList.RCode,
                                DocumentNumber = SINo
                            };
                            ManageGatePass gatePass = new ManageGatePass();
                            gatePass.InsertGatePass(gatePassEntity);
                        }
                        //lock (gatePass)
                        //{
                        //    Task.Run(() => gatePass.InsertGatePass(gatePassEntity));
                        //}
                    }

                    //#if (!DEBUG)
                    ManageDocumentIssues documentIssues = new ManageDocumentIssues();
                    Task.Run(() => documentIssues.GenerateIssues(issueList));

                    //if (isNewDoc)
                    //{
                    //    ManageDataTransfer dataTransfer = new ManageDataTransfer();
                    //    DataTransferEntity transferEntity = new DataTransferEntity();
                    //    transferEntity.DocNumber = SINo;
                    //    transferEntity.DocType = 2;
                    //    transferEntity.TripType = 2;
                    //    transferEntity.RCode = issueList.RCode;
                    //    transferEntity.GCode = issueList.IssuingCode;
                    //    // dataTransfer.InsertDataTransfer(transferEntity);
                    //    Task.Run(() => dataTransfer.InsertDataTransfer(transferEntity));

                    //}


                    //   Delete Stock issue Item Details
                    sqlCommand.Parameters.Clear();
                    sqlCommand.Dispose();

                    sqlCommand             = new SqlCommand();
                    sqlCommand.Transaction = objTrans;
                    sqlCommand.Connection  = sqlConnection;
                    sqlCommand.CommandText = "DeleteSIItemDetails";
                    sqlCommand.CommandType = CommandType.StoredProcedure;
                    sqlCommand.Parameters.AddWithValue("@SINo", SINo);
                    sqlCommand.ExecuteNonQuery();

                    //Insert data into SI Item details

                    List <DocumentStockIssuesItemEntity> stockIssuesItemEntities = new List <DocumentStockIssuesItemEntity>();
                    stockIssuesItemEntities = issueList.IssueItemList;
                    foreach (var item in stockIssuesItemEntities)
                    {
                        if (item.TStockNo.ToUpper() != "TOTAL")
                        {
                            sqlCommand.Parameters.Clear();
                            sqlCommand.Dispose();

                            sqlCommand             = new SqlCommand();
                            sqlCommand.Transaction = objTrans;
                            sqlCommand.Connection  = sqlConnection;
                            sqlCommand.CommandText = "InsertSIItemDetails";
                            sqlCommand.CommandType = CommandType.StoredProcedure;
                            sqlCommand.Parameters.AddWithValue("@RowId", RowID);
                            sqlCommand.Parameters.AddWithValue("@SINo", SINo);
                            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", issueList.RCode);
                            sqlCommand.Parameters.AddWithValue("@ExportFlag", "N");
                            sqlCommand.Parameters.AddWithValue("@flag1", item.StackYear); //StackYear
                            sqlCommand.Parameters.AddWithValue("@Flag2", "-");
                            sqlCommand.ExecuteNonQuery();
                        }
                    }

                    //Insert data into IssueMemoDoNo Item details

                    List <DocumentStockIssueDetailsEntity> stockIssueDetailsEntities = new List <DocumentStockIssueDetailsEntity>();
                    stockIssueDetailsEntities = issueList.SIDetailsList;
                    foreach (var item in stockIssueDetailsEntities)
                    {
                        sqlCommand.Parameters.Clear();
                        sqlCommand.Dispose();

                        sqlCommand             = new SqlCommand();
                        sqlCommand.Transaction = objTrans;
                        sqlCommand.Connection  = sqlConnection;
                        sqlCommand.CommandText = "InsertIssuememodono";
                        sqlCommand.CommandType = CommandType.StoredProcedure;
                        sqlCommand.Parameters.AddWithValue("@Issuememono", SINo);
                        sqlCommand.Parameters.AddWithValue("@IssueMemoDate", item.SIDate);
                        sqlCommand.Parameters.AddWithValue("@DeliveryOrderNo", item.DNo);
                        sqlCommand.Parameters.AddWithValue("@DeliveryOrderDate", item.DDate);
                        sqlCommand.Parameters.AddWithValue("@Godowncode", item.GodownCode);
                        sqlCommand.Parameters.AddWithValue("@RCode", issueList.RCode);
                        sqlCommand.Parameters.AddWithValue("@ExportFlag", "N");
                        sqlCommand.Parameters.AddWithValue("@RowId", RowID);
                        sqlCommand.Parameters.AddWithValue("@Flag1", "-");
                        sqlCommand.Parameters.AddWithValue("@Flag2", "-");
                        sqlCommand.ExecuteNonQuery();
                    }
                    System.Threading.Thread.Sleep(100);
                    objTrans.Commit();
                    sqlCommand.Parameters.Clear();
                    sqlCommand.Dispose();

                    return(new Tuple <bool, string, string>(true, GlobalVariable.SavedMessage + SINo, SINo));
                }
                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();
                    isNewDoc = false;
                }
            }
        }
Esempio n. 3
0
        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;
                }
            }
        }