Ejemplo n.º 1
0
        public static List <MCTransaction> GetMCInterBranch(string criteria, int branchID)
        {
            var dbUtil         = new DatabaseManager();
            var mcTransactions = new List <MCTransaction>();

            using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB")))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandType    = CommandType.StoredProcedure;
                    cmd.CommandText    = "spInvGetMCInterBranchTransfer";
                    cmd.CommandTimeout = 180;
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@strCriteria", criteria);
                    cmd.Parameters.AddWithValue("@intIDMasLocation", branchID);

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var mcTransaction = new MCTransaction
                            {
                                MCTransactionID      = ReferenceEquals(reader["intIDInvMCTran"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDInvMCTran"]),
                                MCTransactionRefTBID = ReferenceEquals(reader["intIDMCTranRefNoTB"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDMCTranRefNoTB"]),
                                OriginatingBranchID  = ReferenceEquals(reader["intIDMasLocationFrom"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDMasLocationFrom"]),
                                OriginatingBranch    = ReferenceEquals(reader["strOriginatingBranch"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strOriginatingBranch"]),
                                ReceivingBranchID    = ReferenceEquals(reader["intIDMasLocationTo"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDMasLocationTo"]),
                                StockTransTypeID     = ReferenceEquals(reader["intIDMasStockTranType"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDMasStockTranType"]),
                                StockTransType       = ReferenceEquals(reader["strStockTransType"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strStockTransType"]),
                                InventoryStatusID    = ReferenceEquals(reader["intIDMasInvStatus"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDMasInvStatus"]),
                                InventoryStatus      = ReferenceEquals(reader["strInventoryStatus"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strInventoryStatus"]),
                                InvOperandID         = ReferenceEquals(reader["intIDMasInvTranOperand"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDMasInvTranOperand"]),
                                InvOperand           = ReferenceEquals(reader["strInventoryOperand"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strInventoryOperand"]),
                                DateInvTran          = ReferenceEquals(reader["datTransact"], DBNull.Value) ? String.Empty : Convert.ToString(reader["datTransact"]),
                                DateInvRefTran       = ReferenceEquals(reader["datInvTranReference"], DBNull.Value) ? String.Empty : Convert.ToString(reader["datInvTranReference"]),
                                EmployeeID1          = ReferenceEquals(reader["intIDMasRefEmployee1"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDMasRefEmployee1"]),
                                EmployeeName1        = ReferenceEquals(reader["strEmployeeName1"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strEmployeeName1"]),
                                EmployeeID2          = ReferenceEquals(reader["intIDMasRefEmployee2"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDMasRefEmployee2"]),
                                EmployeeName2        = ReferenceEquals(reader["strEmployeeName2"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strEmployeeName2"]),
                                CustomerID           = ReferenceEquals(reader["intIDMasCustomer"], DBNull.Value) ? 0 : Convert.ToInt32(reader["intIDMasCustomer"]),
                                CustomerName         = ReferenceEquals(reader["strCustName"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strCustName"]),
                                Remarks       = ReferenceEquals(reader["strRemarks"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strRemarks"]),
                                ReferenceNo   = ReferenceEquals(reader["strReferenceNo"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strReferenceNo"]),
                                ShippedVia    = ReferenceEquals(reader["strShippedVia"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strShippedVia"]),
                                DateShipped   = ReferenceEquals(reader["datShipped"], DBNull.Value) ? String.Empty : Convert.ToString(reader["datShipped"]),
                                TotalCost     = ReferenceEquals(reader["curTotalCost"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["curTotalCost"]),
                                TotalSRP      = ReferenceEquals(reader["curTotalSRP"], DBNull.Value) ? 0 : Convert.ToDecimal(reader["curTotalSRP"]),
                                ReferenceGLNo = ReferenceEquals(reader["strReferenceGLNo"], DBNull.Value) ? String.Empty : Convert.ToString(reader["strReferenceGLNo"])
                            };

                            mcTransactions.Add(mcTransaction);
                        }

                        return(mcTransactions);
                    }
                }
            }
        }
        // Receiving From Service Unit - Start

        public static string ManageMCTransactionRSU(NameValueCollection querystring, NameValueCollection formdata)
        {
            int     intParser;
            decimal decimalParser;

            UserProfile userProfile = WebCommon.GetUserProfile();

            var MCTransactionDetails = new List <MCTransactionDetail>();

            MCTransactionDetails = (List <MCTransactionDetail>)MCTransactionDetails.ToClass(formdata["MCData"]);

            var RSUentry = new List <clsRSUentry>();

            RSUentry = (List <clsRSUentry>)RSUentry.ToClass(formdata["RSUEntryData"]);


            var MCTransactions = new MCTransaction
            {
                MCTransactionID      = int.TryParse(querystring.Get("MCTransactionID"), out intParser) ? intParser : 0,
                MCTransactionRefTBID = int.TryParse(querystring.Get("MCTransactionRefTBID"), out intParser) ? intParser : 0,
                BranchID             = int.TryParse(querystring.Get("BranchID"), out intParser) ? intParser : 0,
                OriginatingBranchID  = int.TryParse(querystring.Get("OriginatingBranchID"), out intParser) ? intParser : 0,
                ReceivingBranchID    = int.TryParse(querystring.Get("ReceivingBranchID"), out intParser) ? intParser : 0,
                StockTransTypeID     = int.TryParse(querystring.Get("StockTransTypeID"), out intParser) ? intParser : 0,
                InventoryStatusID    = int.TryParse(querystring.Get("InventoryStatusID"), out intParser) ? intParser : 0,
                InvOperandID         = int.TryParse(querystring.Get("InvOperandID"), out intParser) ? intParser : 0,
                DateInvTran          = querystring.Get("DateInvTran"),
                DateInvRefTran       = querystring.Get("DateInvRefTran"),
                EmployeeID1          = int.TryParse(querystring.Get("EmployeeID1"), out intParser) ? intParser : 0,
                EmployeeID2          = int.TryParse(querystring.Get("EmployeeID2"), out intParser) ? intParser : 0,
                ReferenceNo          = querystring.Get("ReferenceNo"),
                Remarks     = querystring.Get("Remarks"),
                ShippedVia  = querystring.Get("ShippedVia"),
                DateShipped = querystring.Get("DateShipped"),
                TotalCost   = decimal.TryParse(querystring.Get("TotalCost"), out decimalParser) ? decimalParser : 0,
                TotalSRP    = decimal.TryParse(querystring.Get("TotalSRP"), out decimalParser) ? decimalParser : 0,

                Details    = MCTransactionDetails,
                UserID     = userProfile.UserId,
                RSUentries = RSUentry
            };

            string isInsert = querystring.Get("TransType");
            string param    = WebCommon.ToXML(MCTransactions);

            return(MCTransactionDAL.ManageMCTransactionRSU(param, isInsert));
        } // Receiving From Service Unit - End