Ejemplo n.º 1
0
        public List <Impm1_Enquiry> Get_Impm1_Enquiry_List(Impm request)
        {
            List <Impm1_Enquiry> Result = null;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection("WMS"))
                {
                    string strSql = "Select IsNull(Impm1.ProductCode,'') AS ProductCode, IsNull(Impm1.ProductName,'') AS ProductName," +
                                    "IsNull(Impm1.GoodsReceiveorIssueNo,'') AS GoodsReceiveorIssueNo, IsNull(Impm1.RefNo,'') AS RefNo," +
                                    "IsNull(Impm1.StoreNo,'') AS StoreNo, " +
                                    "(CASE Impm1.DimensionFlag When '1' THEN Impm1.BalancePackingQty When '2' THEN Impm1.BalanceWholeQty ELSE Impm1.BalanceLooseQty END) AS BalanceQty " +
                                    "From Impm1 Where ";
                    string strFilter = " (CASE Impm1.DimensionFlag When '1' THEN Impm1.BalancePackingQty When '2' THEN Impm1.BalanceWholeQty ELSE Impm1.BalanceLooseQty END) >0 ";
                    if (!string.IsNullOrEmpty(request.ProductCode))
                    {
                        strFilter = strFilter + " AND ProductCode='" + Modfunction.SQLSafe(request.ProductCode) + "'";
                    }
                    else if (!string.IsNullOrEmpty(request.WarehouseCode) && !string.IsNullOrEmpty(request.StoreNo))
                    {
                        strFilter = strFilter + " AND WarehouseCode='" + Modfunction.SQLSafe(request.WarehouseCode) + "' And StoreNo='" + Modfunction.SQLSafe(request.StoreNo) + "'";
                    }
                    else if (!string.IsNullOrEmpty(request.ProductTrxNo))
                    {
                        strFilter = strFilter + " AND ProductTrxNo = " + int.Parse(request.ProductTrxNo);
                    }
                    Result = db.Select <Impm1_Enquiry>(strSql + strFilter);
                }
            }
            catch { throw; }
            return(Result);
        }
Ejemplo n.º 2
0
        public int Update_Saal(Saal request)
        {
            int Result    = -1;
            int intResult = -1;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection("WMS"))
                {
                    if (request.PrimaryKeyLineItemNo > 0)
                    {
                        intResult = db.Scalar <int>(
                            "Select Max(lineItemNo) from saal1 where Tablename = {0} AND PrimaryKeyName = {1} AND PrimaryKeyValue = {2} and PrimaryKeyLineItemNo = {3}",
                            request.TableName, request.PrimaryKeyName, request.PrimaryKeyValue, request.PrimaryKeyLineItemNo
                            );
                        if (request.TableName == "Imgr2" || request.TableName == "Imgi2")
                        {
                            db.ExecuteSql("Update " + request.TableName + " Set " + request.FieldName +
                                          " = " + Modfunction.SQLSafeValue(request.NewValue) + " Where TrxNo = " +
                                          Modfunction.SQLSafeValue(request.PrimaryKeyValue) + " AND LineItemNo = " +
                                          Modfunction.SQLSafeValue(request.PrimaryKeyLineItemNo.ToString()));
                        }
                    }
                    else
                    {
                        intResult = db.Scalar <int>(
                            "Select Max(lineItemNo) from saal1 where Tablename = {0} AND PrimaryKeyName = {1} AND PrimaryKeyValue = {2} ",
                            request.TableName, request.PrimaryKeyName, request.PrimaryKeyValue
                            );
                    }
                    if (intResult > 0)
                    {
                        intResult = intResult + 1;
                    }
                    else
                    {
                        intResult = 1;
                    }
                    if (request.PrimaryKeyLineItemNo > 0)
                    {
                        db.ExecuteSql("insert into saal1 (Tablename, PrimaryKeyName, PrimaryKeyValue,PrimaryKeyLineItemNo ,LineItemNo, FieldName, NewValue, OldValue) values ('" +
                                      Modfunction.SQLSafe(request.TableName) + "','" + Modfunction.SQLSafe(request.PrimaryKeyName) + "'," + Modfunction.SQLSafeValue(request.PrimaryKeyValue) + "," + Modfunction.SQLSafeValue(request.PrimaryKeyLineItemNo.ToString()) + "," + intResult.ToString() + ",'" +
                                      Modfunction.SQLSafe(request.FieldName) + "'," + Modfunction.SQLSafeValue(request.NewValue) + "," + Modfunction.SQLSafeValue(request.OldValue) + ")");
                    }
                    else
                    {
                        db.ExecuteSql("insert into saal1 (Tablename, PrimaryKeyName, PrimaryKeyValue,PrimaryKeyLineItemNo ,LineItemNo, FieldName, NewValue, OldValue) values ('" +
                                      Modfunction.SQLSafe(request.TableName) + "','" + Modfunction.SQLSafe(request.PrimaryKeyName) + "'," + Modfunction.SQLSafeValue(request.PrimaryKeyValue) + "," + Modfunction.SQLSafeValue(request.PrimaryKeyLineItemNo.ToString()) + "," + intResult.ToString() + ",'" +
                                      Modfunction.SQLSafe(request.FieldName) + "'," + Modfunction.SQLSafeValue(request.NewValue) + "," + Modfunction.SQLSafeValue(request.OldValue) + ")");
                    }
                }
            }
            catch { throw; }
            return(Result);
        }
Ejemplo n.º 3
0
        public int ConfirmAll_Jmjm1(Jmjm request)
        {
            int Result = -1;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection())
                {
                    if (request.confirmAllString != null && request.confirmAllString != "")
                    {
                        JArray ja = (JArray)JsonConvert.DeserializeObject(request.confirmAllString);
                        if (ja != null)
                        {
                            for (int i = 0; i < ja.Count(); i++)
                            {
                                string strJobNo             = "";
                                string strActualArrivalDate = "";
                                string strDeliveryDate      = "";
                                if (ja[i]["JobNo"] != null || ja[i]["JobNo"].ToString() != "")
                                {
                                    strJobNo = ja[i]["JobNo"].ToString();
                                }
                                strActualArrivalDate = ja[i]["ActualArrivalDate"].ToString();
                                strDeliveryDate      = ja[i]["DeliveryDate"].ToString();
                                if (strJobNo != "")
                                {
                                    if (strActualArrivalDate != "")
                                    {
                                        db.Update("Jmjm3",
                                                  " DateTime = '" + Modfunction.SQLSafe(strActualArrivalDate) + "'",
                                                  " JobNo='" + strJobNo + "' and Description = 'ACTUAL ARRIVAL DATE'");
                                    }
                                    if (strDeliveryDate != "")
                                    {
                                        db.Update("Jmjm1",
                                                  " DeliveryDateTime = '" + Modfunction.SQLSafe(strDeliveryDate) + "'",
                                                  " JobNo='" + strJobNo + "'");
                                    }
                                }
                            }
                            Result = 1;
                        }
                    }
                }
            }
            catch { throw; }
            return(Result);
        }
Ejemplo n.º 4
0
        public Impr1 Get_Impr1_Single(Impr request)
        {
            Impr1 Result = null;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection("WMS"))
                {
                    List <Impa1> impa1           = db.Select <Impa1>("Select * from Impa1");
                    string       strBarCodeFiled = impa1[0].BarCodeField;
                    string[]     strBarCodeList  = strBarCodeFiled.Split(',');
                    if (strBarCodeList.Length <= 1)
                    {
                        string strSql = "Select * From Impr1 Where IsNull(ProductCode,'')<>'' And IsNull(StatusCode,'')<>'DEL' And " + strBarCodeFiled + "='" + Modfunction.SQLSafe(request.BarCode) + "'";
                        Result = db.QuerySingle <Impr1>(strSql);
                    }
                    else
                    {
                        string strBarCodeFilter = "";
                        for (int i = 0; i < strBarCodeList.Length; i++)
                        {
                            if (strBarCodeFilter == "")
                            {
                                strBarCodeFilter = strBarCodeList[i] + "='" + Modfunction.SQLSafe(request.BarCode) + "'";
                            }
                            else
                            {
                                strBarCodeFilter = strBarCodeFilter + " OR " + strBarCodeList[i] + "='" + Modfunction.SQLSafe(request.BarCode) + "'";
                            }
                        }
                        if (strBarCodeFilter != "")
                        {
                            string strSql = "Select * From Impr1 Where IsNull(ProductCode,'')<>'' And IsNull(StatusCode,'')<>'DEL' And (" + strBarCodeFilter + ")";
                            Result = db.QuerySingle <Impr1>(strSql);
                        }
                        else
                        {
                            string strSql = "Select top 0 * From Impr1 ";
                            Result = db.QuerySingle <Impr1>(strSql);
                        }
                    }
                }
            }
            catch { throw; }
            return(Result);
        }
Ejemplo n.º 5
0
        public object Get_Impm1_Transfer_List(Impm request)
        {
            List <Impm1_Transfer_Tree> ResultTrees = new List <Impm1_Transfer_Tree>();
            List <Impm1_Transfer>      Results     = null;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection("WMS"))
                {
                    string strSql = "Select Impm1.TrxNo, Impm1.BatchLineItemNo, IsNull(BatchNo,'') AS name, IsNull(ProductCode,'') AS ProductCode," +
                                    "IsNull(ProductName,'') AS ProductName, IsNull(GoodsReceiveorIssueNo,'') AS GoodsReceiveorIssueNo, IsNull(UserDefine1,'') AS UserDefine1," +
                                    "b.QtyBal, '' AS FromToStoreNo, 0 AS ScanQty " +
                                    "From Impm1 Join (Select (Select top 1 Imit1.StatusCode from imit1 Where imit1.GoodsTransferNoteNo = a.GoodsReceiveorIssueNo) AS ImitStatus, a.TrxNo, " +
                                    "(CASE a.DimensionFlag When '1' THEN a.BalancePackingQty When '2' THEN a.BalanceWholeQty ELSE a.BalanceLooseQty END) AS QtyBal From Impm1 a ) b on b.TrxNo = impm1.TrxNo " +
                                    "Where WarehouseCode='" + Modfunction.SQLSafe(request.WarehouseCode) + "' And StoreNo='" + Modfunction.SQLSafe(request.StoreNo) + "' And (b.ImitStatus = 'EXE' or ImitStatus is null) And b.QtyBal>0";
                    Results = db.Select <Impm1_Transfer>(strSql);
                    for (int i = 0; i < Results.Count; i++)
                    {
                        string         BatchNo         = Results[i].name;
                        Impm1_Transfer impm1           = Results[i];
                        bool           blnExistBatchNo = false;
                        foreach (Impm1_Transfer_Tree ResultTree in ResultTrees)
                        {
                            if (ResultTree.name.Equals(BatchNo))
                            {
                                blnExistBatchNo = true;
                                ResultTree.tree.Add(impm1);
                            }
                        }
                        if (!blnExistBatchNo)
                        {
                            Impm1_Transfer_Tree impm1_tree = new Impm1_Transfer_Tree();
                            impm1_tree.name = BatchNo;
                            impm1_tree.tree = new List <Impm1_Transfer>();
                            impm1_tree.tree.Add(impm1);
                            ResultTrees.Add(impm1_tree);
                        }
                    }
                }
            }
            catch { throw; }
            return(ResultTrees);
        }
Ejemplo n.º 6
0
        public List <Imgr2_Receipt> Get_Imgr2_Receipt_List(Imgr request)
        {
            List <Imgr2_Receipt> Result = null;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection("WMS"))
                {
                    string strSql = "Select Imgr2.*,'' As QtyStatus, " +
                                    "" + getBarCodeListSelect() +
                                    "(Select Top 1 SerialNoFlag From Impr1 Where TrxNo=Imgr2.ProductTrxNo) AS SerialNoFlag," +
                                    "0 AS ScanQty,GoodsReceiptNoteNo " +
                                    "From Imgr2 " +
                                    "Left Join Imgr1 On Imgr2.TrxNo = Imgr1.TrxNo " +
                                    "Where Imgr1.GoodsReceiptNoteNo='" + Modfunction.SQLSafe(request.GoodsReceiptNoteNo) + "'";
                    Result = db.Select <Imgr2_Receipt>(strSql);
                }
            }
            catch { throw; }
            return(Result);
        }
Ejemplo n.º 7
0
        public int UpdateAll_Aemp1WithAido1(Aemp_Aido request)
        {
            int Result = -1;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection())
                {
                    if (request.UpdateAllString != null && request.UpdateAllString != "")
                    {
                        JArray ja = (JArray)JsonConvert.DeserializeObject(request.UpdateAllString);
                        if (ja != null)
                        {
                            for (int i = 0; i < ja.Count(); i++)
                            {
                                if (ja[i]["TableName"] == null || ja[i]["TableName"].ToString() == "")
                                {
                                    continue;
                                }
                                string strKey        = ja[i]["Key"].ToString();
                                string strTableName  = ja[i]["TableName"].ToString();
                                string strRemark     = "";
                                string strStatusCode = "";
                                if (ja[i]["Remark"] != null || ja[i]["Remark"].ToString() != "")
                                {
                                    strRemark = ja[i]["Remark"].ToString();
                                }
                                if (ja[i]["StatusCode"] != null || ja[i]["StatusCode"].ToString() != "")
                                {
                                    strStatusCode = ja[i]["StatusCode"].ToString();
                                }
                                if (strStatusCode.ToLower() == "cancel")
                                {
                                    string strJobNo = "";
                                    if (ja[i]["JobNo"] != null || ja[i]["JobNo"].ToString() != "")
                                    {
                                        strJobNo = ja[i]["JobNo"].ToString();
                                    }
                                    if (strJobNo != "")
                                    {
                                        int          intMaxLineItemNo = 1;
                                        List <Jmjm3> list1            = db.Select <Jmjm3>("Select Max(LineItemNo) LineItemNo from Jmjm3 Where JobNo = " + Modfunction.SQLSafeValue(strJobNo));
                                        if (list1 != null)
                                        {
                                            if (list1[0].LineItemNo > 0)
                                            {
                                                intMaxLineItemNo = list1[0].LineItemNo + 1;
                                            }
                                        }
                                        db.Insert(new Jmjm3
                                        {
                                            JobNo          = strJobNo,
                                            DateTime       = DateTime.Now,
                                            UpdateDatetime = DateTime.Now,
                                            LineItemNo     = intMaxLineItemNo,
                                            AutoFlag       = "N",
                                            StatusCode     = "CANCEL",
                                            UpdateBy       = ja[0]["DriverCode"] == null ? "" : Modfunction.SQLSafe(ja[0]["DriverCode"].ToString()),
                                            Remark         = Modfunction.SQLSafe(strRemark),
                                            Description    = ja[0]["CancelDescription"] == null ? "" : Modfunction.SQLSafe(ja[0]["CancelDescription"].ToString())
                                        });
                                        if (strTableName == "Aemp1")
                                        {
                                            db.Update(strTableName,
                                                      " Remark = '" + Modfunction.SQLSafe(strRemark) + "'",
                                                      " TrxNo='" + strKey + "'");
                                        }
                                        else if (strTableName == "Sido1")
                                        {
                                            db.Update(strTableName,
                                                      " Remark = '" + Modfunction.SQLSafe(strRemark) + "'",
                                                      " TrxNo='" + strKey + "'");
                                        }

                                        else
                                        {
                                            db.Update(strTableName,
                                                      " Remark = '" + Modfunction.SQLSafe(strRemark) + "'",
                                                      " DeliveryOrderNo='" + strKey + "'");
                                        }
                                    }
                                }
                                else
                                {
                                    if (strTableName == "Aemp1")
                                    {
                                        db.Update(strTableName,
                                                  " Remark = '" + Modfunction.SQLSafe(strRemark) + "',StatusCode = '" + strStatusCode + "',SignBy='" + Modfunction.CheckNull(request.SignBy) + "'",
                                                  " TrxNo='" + strKey + "'");
                                    }
                                    else if (strTableName == "Sido1")
                                    {
                                        db.Update(strTableName,
                                                  " Remark = '" + Modfunction.SQLSafe(strRemark) + "',StatusCode = '" + strStatusCode + "',SignBy='" + Modfunction.CheckNull(request.SignBy) + "'",
                                                  " TrxNo='" + strKey + "'");
                                    }
                                    else
                                    {
                                        db.Update(strTableName,
                                                  " Remark = '" + Modfunction.SQLSafe(strRemark) + "',StatusCode = '" + strStatusCode + "',SignBy='" + Modfunction.CheckNull(request.SignBy) + "'",
                                                  " DeliveryOrderNo='" + strKey + "'");
                                    }
                                }
                            }
                            Result = 1;
                        }
                    }
                }
            }
            catch { throw; }
            return(Result);
        }
Ejemplo n.º 8
0
        public List <Impm1_UserDefine> Get_Impm1_List(Impm request)
        {
            List <Impm1_UserDefine> Result = null;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection("WMS"))
                {
                    List <Impa1> impa1           = db.Select <Impa1>("Select * from Impa1");
                    string       strBarCodeFiled = impa1[0].BarCodeField;
                    string[]     strBarCodeList  = strBarCodeFiled.Split(',');
                    string       strSql          = "";
                    string       strSqlDetail    = "";
                    if (strBarCodeList.Length <= 1)
                    {
                        strSqlDetail = "Select Cast(" + strBarCodeFiled + " AS nvarchar(2000)) AS UserDefine1,TrxNo from Impr1 Where " + strBarCodeFiled + " = '" + Modfunction.SQLSafe(request.UserDefine1) + "'";
                    }
                    else
                    {
                        for (int i = 0; i < strBarCodeList.Length; i++)
                        {
                            string strSqlNew = "Select Cast(" + strBarCodeList[i] + " AS nvarchar(2000)) AS UserDefine1,TrxNo from Impr1 Where " + strBarCodeList[i] + " = '" + Modfunction.SQLSafe(request.UserDefine1) + "'";
                            if (strSqlDetail == "")
                            {
                                strSqlDetail = strSqlNew;
                            }
                            else
                            {
                                strSqlDetail = strSqlDetail + " union all " + strSqlNew;
                            }
                        }
                    }
                    if (strSqlDetail != "")
                    {
                        strSql = "Select Top 10 * From (" + strSqlDetail + ") a " +
                                 "Order By a.UserDefine1 ASC";
                        Result = db.Select <Impm1_UserDefine>(strSql);
                    }
                }
            }
            catch { throw; }
            return(Result);
        }
        public List <Imgi1> Get_Imgi1_List(Imgi request)
        {
            List <Imgi1> Result = null;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection("WMS"))
                {
                    if (!string.IsNullOrEmpty(request.CustomerCode))
                    {
                        if (!string.IsNullOrEmpty(request.StatusCode))
                        {
                            Result = db.Select <Imgi1>("Select * from imgi1 where StatusCode = 'EXE' AND Convert(Char(10), IssueDateTime, 20) = Convert(Char(10), getdate(), 20) AND CustomerCode = " + Modfunction.SQLSafeValue(request.CustomerCode));
                            //Result = db.SelectParam<Imgi1>(
                            //            i => i.CustomerCode != null && i.CustomerCode != "" && i.StatusCode != null && i.StatusCode != "DEL" && i.StatusCode != "EXE" && i.CustomerCode == request.CustomerCode
                            //).OrderByDescending(i => i.IssueDateTime).ToList<Imgi1>();
                        }
                        else
                        {
                            Result = db.SelectParam <Imgi1>(
                                i => i.CustomerCode != null && i.CustomerCode != "" && i.StatusCode != null && i.StatusCode != "DEL" && i.StatusCode != "EXE" && i.StatusCode != "CMP" && i.CustomerCode == request.CustomerCode
                                ).OrderByDescending(i => i.IssueDateTime).ToList <Imgi1>();
                        }
                    }
                    else if (!string.IsNullOrEmpty(request.GoodsIssueNoteNo))
                    {
                        if (!string.IsNullOrEmpty(request.StatusCode))
                        {
                            Result = db.Select <Imgi1>("Select * from imgi1 where StatusCode = 'EXE' AND Convert(Char(10), IssueDateTime, 20) = Convert(Char(10), getdate(), 20) AND GoodsIssueNoteNo like '" + Modfunction.SQLSafe(request.GoodsIssueNoteNo) + "%'");
                            //Result = db.SelectParam<Imgi1>(
                            //                i => i.CustomerCode != null && i.CustomerCode != "" && i.StatusCode != null && i.StatusCode != "DEL" && i.StatusCode != "EXE" && i.GoodsIssueNoteNo.StartsWith(request.GoodsIssueNoteNo)
                            //).OrderByDescending(i => i.IssueDateTime).ToList<Imgi1>();
                        }
                        else
                        {
                            Result = db.SelectParam <Imgi1>(
                                i => i.CustomerCode != null && i.CustomerCode != "" && i.StatusCode != null && i.StatusCode != "DEL" && i.StatusCode != "EXE" && i.StatusCode != "CMP" && i.GoodsIssueNoteNo.StartsWith(request.GoodsIssueNoteNo)
                                ).OrderByDescending(i => i.IssueDateTime).ToList <Imgi1>();
                        }
                    }
                }
            }
            catch { throw; }
            return(Result);
        }
Ejemplo n.º 10
0
        public List <Imgi2_Verify> Get_Imgi2_Verify_List(Imgi request)
        {
            List <Imgi2_Verify> Result = null;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection("WMS"))
                {
                    string strSql = "";
                    strSql = "Select RowNum = ROW_NUMBER() OVER (ORDER BY Imgi2.StoreNo ASC), " +
                             "Imgi2.*, " +
                             "(Select Top 1 UserDefine1 From Impm1 Where TrxNo=Imgi2.ReceiptMovementTrxNo) AS SerialNo," +
                             "" + getBarCodeListSelect() +
                             "(Select Top 1 SerialNoFlag From Impr1 Where TrxNo=Imgi2.ProductTrxNo) AS SerialNoFlag," +
                             "(CASE Imgi2.DimensionFlag When '1' THEN Imgi2.PackingQty When '2' THEN Imgi2.WholeQty ELSE Imgi2.LooseQty END) AS Qty, " +
                             "0 AS QtyBal, 0 AS ScanQty,ReceiptMovementTrxNo " +
                             "From Imgi2 " +
                             "Left Join Imgi1 On Imgi2.TrxNo=Imgi1.TrxNo " +
                             "Where (IsNull(Imgi1.StatusCode,'')='USE' Or IsNull(Imgi1.StatusCode,'')='CMP') And Imgi1.GoodsIssueNoteNo='" + Modfunction.SQLSafe(request.GoodsIssueNoteNo) + "'";
                    Result = db.Select <Imgi2_Verify>(strSql);
                }
            }
            catch { throw; }
            return(Result);
        }
Ejemplo n.º 11
0
        public int ConfirmAll_Jmjm1(Jmjm request)
        {
            int Result = -1;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection())
                {
                    if (request.confirmAllString != null && request.confirmAllString != "")
                    {
                        JArray ja = (JArray)JsonConvert.DeserializeObject(request.confirmAllString);
                        if (ja != null)
                        {
                            for (int i = 0; i < ja.Count(); i++)
                            {
                                string strJobNo             = "";
                                string strActualArrivalDate = "";
                                string strDeliveryDate      = "";
                                if (ja[i]["JobNo"] != null || ja[i]["JobNo"].ToString() != "")
                                {
                                    strJobNo = ja[i]["JobNo"].ToString();
                                }
                                strActualArrivalDate = ja[i]["ActualArrivalDate"].ToString();
                                strDeliveryDate      = ja[i]["DeliveryDate"].ToString();
                                if (strJobNo != "")
                                {
                                    if (strActualArrivalDate != "")
                                    {
                                        int count = db.Scalar <int>("Select Count(JobNo) from Jmjm3 where JobNo='" + Modfunction.SQLSafe(strJobNo) + "' and Description = 'ACTUAL ARRIVAL DATE'");
                                        if (count > 0)
                                        {
                                            db.Update("Jmjm3",
                                                      " DateTime = '" + Modfunction.SQLSafe(strActualArrivalDate) + "'",
                                                      " JobNo='" + Modfunction.SQLSafe(strJobNo) + "' and Description = 'ACTUAL ARRIVAL DATE'");
                                        }
                                        else
                                        {
                                            count = db.Scalar <int>("Select Max(LineItemNo) from Jmjm3 where JobNo='" + Modfunction.SQLSafe(strJobNo) + "'");
                                            count = count + 1;
                                            string updateBy = db.Scalar <string>("Select DeliveryAgentCode from jmjm1 Where JobNo='" + Modfunction.SQLSafe(strJobNo) + "'");
                                            db.Insert(new Jmjm3
                                            {
                                                JobNo          = strJobNo,
                                                DateTime       = Convert.ToDateTime(strActualArrivalDate),
                                                UpdateDatetime = DateTime.Now,
                                                LineItemNo     = count,
                                                AutoFlag       = "N",
                                                StatusCode     = "",
                                                UpdateBy       = updateBy,
                                                Description    = "ACTUAL ARRIVAL DATE"
                                            });
                                        }
                                    }
                                    if (strDeliveryDate != "")
                                    {
                                        db.Update("Jmjm1",
                                                  " DeliveryDateTime = '" + Modfunction.SQLSafe(strDeliveryDate) + "'",
                                                  " JobNo='" + strJobNo + "'");
                                    }
                                }
                            }
                            Result = 1;
                        }
                    }
                }
            }
            catch { throw; }
            return(Result);
        }
Ejemplo n.º 12
0
        private string CreateGoodsReceiptNo(DataTable dt, string strNumberType)
        {
            string functionReturnValue = null;
            int    intI                 = 0;
            string m_strJobSeqNo        = "";
            string m_strPullFrom        = "";
            string m_strUpdateNextField = "";
            int    intMonth             = 0;
            string strGoodsReceiptNo    = null;
            int    intYear              = 0;

            string[]  strArr           = null;
            DataTable dtRec            = null;
            DataTable dtRec2           = null;
            string    m_SQlCommandText = null;

            functionReturnValue = "";
            m_SQlCommandText    = "Select * From Sanm1 Where NumberType = '" + strNumberType + "' Order By JobType Desc";
            dtRec = GetSQLCommandReturnDT(m_SQlCommandText);
            if ((dtRec != null))
            {
                if (dtRec.Rows.Count > 0)
                {
                    if (dtRec.Rows[0]["Cycle"] == null)
                    {
                        return(functionReturnValue);
                    }
                    //Cycle = Continuous
                    if (dtRec.Rows[0]["Cycle"].ToString() == "C")
                    {
                        m_strPullFrom = "NextNo";
                        m_strJobSeqNo = Modfunction.CheckNull(dtRec.Rows[0]["NextNo"]);
                        //Cycle = Month
                    }
                    else if (Modfunction.CheckNull(dtRec.Rows[0]["Cycle"]) == "M")
                    {
                        intMonth         = DateTime.Now.Month;
                        intYear          = DateTime.Now.Year;
                        m_SQlCommandText = "Select * From Sanm2 Where TrxNo = " + Modfunction.CheckNull(dtRec.Rows[0]["TrxNo"]) + " And Year = '" + intYear + "'";
                        dtRec2           = GetSQLCommandReturnDT(m_SQlCommandText);
                        if ((dtRec2 != null))
                        {
                            if (dtRec2.Rows.Count > 0)
                            {
                                switch (intMonth)
                                {
                                case 1:
                                    m_strPullFrom = "Mth01NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth01NextNo"].ToString();
                                    break;

                                case 2:
                                    m_strPullFrom = "Mth02NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth02NextNo"].ToString();
                                    break;

                                case 3:
                                    m_strPullFrom = "Mth03NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth03NextNo"].ToString();
                                    break;

                                case 4:
                                    m_strPullFrom = "Mth04NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth04NextNo"].ToString();
                                    break;

                                case 5:
                                    m_strPullFrom = "Mth05NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth05NextNo"].ToString();
                                    break;

                                case 6:
                                    m_strPullFrom = "Mth06NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth06NextNo"].ToString();
                                    break;

                                case 7:
                                    m_strPullFrom = "Mth07NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth07NextNo"].ToString();
                                    break;

                                case 8:
                                    m_strPullFrom = "Mth08NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth08NextNo"].ToString();
                                    break;

                                case 9:
                                    m_strPullFrom = "Mth09NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth09NextNo"].ToString();
                                    break;

                                case 10:
                                    m_strPullFrom = "Mth10NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth10NextNo"].ToString();
                                    break;

                                case 11:
                                    m_strPullFrom = "Mth11NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth11NextNo"].ToString();
                                    break;

                                case 12:
                                    m_strPullFrom = "Mth12NextNo";
                                    m_strJobSeqNo = dtRec2.Rows[0]["Mth12NextNo"].ToString();
                                    break;
                                }
                            }
                            else
                            {
                                return(functionReturnValue);
                            }
                        }
                        //No flag = Year
                    }
                    else if (Modfunction.CheckNull(dtRec.Rows[0]["Cycle"]) == "Y")
                    {
                        intYear          = DateTime.Now.Year;
                        m_SQlCommandText = "Select YearNextNo From Sanm2 Where TrxNo = " + Modfunction.CheckNull(dtRec.Rows[0]["TrxNo"]) + " And Year = '" + intYear + "'";
                        dtRec2           = GetSQLCommandReturnDT(m_SQlCommandText);
                        if ((dtRec2 != null))
                        {
                            if (dtRec2.Rows.Count > 0)
                            {
                                m_strPullFrom = "YearNextNo";
                                m_strJobSeqNo = Modfunction.CheckNull(dtRec2.Rows[0]["YearNextNo"]);
                            }
                            else
                            {
                                return(functionReturnValue);
                            }
                        }
                    }
                    strGoodsReceiptNo = "";
                    if (Modfunction.CheckNull(dtRec.Rows[0]["Prefix"]) != "")
                    {
                        strArr = System.Text.RegularExpressions.Regex.Split(dtRec.Rows[0]["Prefix"].ToString(), ",");
                        for (intI = 0; intI <= strArr.Length; intI++)
                        {
                            strGoodsReceiptNo = strGoodsReceiptNo + ReturnPrefixSuffix(strArr[intI], dt);
                        }
                    }
                    strGoodsReceiptNo = strGoodsReceiptNo + m_strJobSeqNo;
                    // & "00"
                    if (Modfunction.CheckNull(dtRec.Rows[0]["Suffix"]).Trim().Length > 0)
                    {
                        strArr = null;
                        strArr = System.Text.RegularExpressions.Regex.Split(dtRec.Rows[0]["Suffix"].ToString(), ",");
                        for (intI = 0; intI <= strArr.Length; intI++)
                        {
                            strGoodsReceiptNo = strGoodsReceiptNo + ReturnPrefixSuffix(strArr[intI], dt);
                        }
                    }
                    functionReturnValue = strGoodsReceiptNo;
                    //120629DC NET3983
                    if (functionReturnValue.Length > 20)
                    {
                        functionReturnValue = functionReturnValue.Substring(functionReturnValue.Length - 20, 20);
                    }
                    m_strUpdateNextField = CheckUpdateFieldLength(m_strJobSeqNo);
                    //Cycle = Continuous
                    if (Modfunction.CheckNull(dtRec.Rows[0]["Cycle"]) == "C")
                    {
                        m_SQlCommandText = "Update Sanm1 Set " + m_strPullFrom + " = '" + Modfunction.SQLSafe(m_strUpdateNextField) + "' Where TrxNo = " + Modfunction.CheckNull(dtRec.Rows[0]["TrxNo"]);
                        //Add 1 For Next Job No
                    }
                    else
                    {
                        m_SQlCommandText = "Update Sanm2 Set " + m_strPullFrom + " = '" + Modfunction.SQLSafe(m_strUpdateNextField) + "' Where TrxNo = " + Modfunction.CheckNull(dtRec.Rows[0]["TrxNo"]) + " And Year = '" + intYear + "'";
                    }
                    GetSQLCommandReturnInt(m_SQlCommandText);
                }
            }
            return(functionReturnValue);
        }
Ejemplo n.º 13
0
        private string SaveImgr(DataTable dtWhScan, DataTable dtOmtx)
        {
            DataTable dtRec         = null;
            string    Result        = "";
            int       intSaveResult = -1;
            DataTable dtImgr1       = GetSQLCommandReturnDT("Select Top 0 * from Imgr1");

            dtImgr1.Columns.Remove(dtImgr1.Columns["TrxNo"]);
            dtImgr1.Columns.Remove(dtImgr1.Columns["CreateDateTime"]);
            dtImgr1.Columns.Remove(dtImgr1.Columns["UpdateDateTime"]);
            dtImgr1.Rows.Add(dtImgr1.NewRow());
            dtImgr1.Rows[0]["CustomerCode"]       = dtWhScan.Rows[0]["CustomerCode"];
            dtImgr1.Rows[0]["WarehouseCode"]      = dtWhScan.Rows[0]["WarehouseCode"];
            dtImgr1.Rows[0]["WarehouseName"]      = dtWhScan.Rows[0]["WarehouseName"];
            dtImgr1.Rows[0]["CustomerName"]       = dtWhScan.Rows[0]["BusinessPartyName"];
            dtImgr1.Rows[0]["CustomerAddress1"]   = dtWhScan.Rows[0]["Address1"];
            dtImgr1.Rows[0]["CustomerAddress2"]   = dtWhScan.Rows[0]["Address2"];
            dtImgr1.Rows[0]["CustomerAddress3"]   = dtWhScan.Rows[0]["Address3"];
            dtImgr1.Rows[0]["CustomerAddress4"]   = dtWhScan.Rows[0]["Address4"];
            dtImgr1.Rows[0]["ReceiptDate"]        = DateTime.Today;
            dtImgr1.Rows[0]["CreateBy"]           = dtWhScan.Rows[0]["ConfirmBy"];
            dtImgr1.Rows[0]["UpdateBy"]           = dtWhScan.Rows[0]["ConfirmBy"];
            dtImgr1.Rows[0]["WorkStation"]        = "PDADriver_" + dtWhScan.Rows[0]["ConfirmBy"].ToString();
            dtImgr1.Rows[0]["GoodsReceiptNoteNo"] = CreateGoodsReceiptNo(dtImgr1, "Imgr");
            if (dtImgr1.Rows[0]["GoodsReceiptNoteNo"] == null || dtImgr1.Rows[0]["GoodsReceiptNoteNo"].ToString() == "")
            {
                dtRec = GetSQLCommandReturnDT("Select NextGoodsReceiptNo From Impa1");
                dtImgr1.Rows[0]["GoodsReceiptNoteNo"] = Modfunction.CheckNull(dtRec.Rows[0][0]);
                string strNewNextGoodsReceiptNo = CheckUpdateFieldLength(Modfunction.CheckNull(dtRec.Rows[0][0])).ToString();
                GetSQLCommandReturnInt("Update Impa1 set NextGoodsReceiptNo = '" + Modfunction.SQLSafe(strNewNextGoodsReceiptNo) + "'");
            }
            intSaveResult = InsertTableRecordByDatatable("Imgr1", dtImgr1);
            if (intSaveResult == -1)
            {
                return("Confirm unsuccess.");
            }
            dtRec = GetSQLCommandReturnDT("Select Max(TrxNo) from Imgr1 Where WorkStation = " + Modfunction.SQLSafeValue(dtImgr1.Rows[0]["WorkStation"]) + " AND CreateBy = " + Modfunction.SQLSafeValue(dtImgr1.Rows[0]["CreateBy"]) + " AND CustomerCode = " + Modfunction.SQLSafeValue(dtImgr1.Rows[0]["CustomerCode"]));
            if (dtRec != null && dtRec.Rows.Count > 0)
            {
                int       intTrxNo = Convert.ToInt32(dtRec.Rows[0][0]);
                DataTable dtImgr2  = GetSQLCommandReturnDT("Select Top 0 from Imgr2 ");
                dtImgr2.Rows.Clear();
                for (int intIndex = 0; intIndex < dtWhScan.Rows.Count; intIndex++)
                {
                    dtRec = GetSQLCommandReturnDT("Select * from Impr1 Where TrxNo = " + Convert.ToInt32(dtWhScan.Rows[intIndex]["ProductTrxNo"]).ToString());
                    if (dtRec != null && dtRec.Rows.Count > 0)
                    {
                        dtImgr2.Rows.Add(dtImgr2.NewRow());
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["TrxNo"]              = intTrxNo;
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["LineItemNo"]         = dtImgr2.Rows.Count;
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["DimensionFlag"]      = dtRec.Rows[0]["DimensionFlag"];
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["UnitVol"]            = dtRec.Rows[0]["UnitVol"];
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["UnitWt"]             = dtRec.Rows[0]["UnitWt"];
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["UnitVolFlag"]        = dtRec.Rows[0]["UnitVolFlag"];
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["ProductTrxNo"]       = dtRec.Rows[0]["TrxNo"];
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["ProductDescription"] = dtRec.Rows[0]["ProductName"];
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["Weight"]             = Convert.ToDecimal(dtRec.Rows[0]["UnitWt"]) * Convert.ToInt32(dtWhScan.Rows[intIndex]["Qty"]);
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["Volume"]             = Convert.ToDecimal(dtRec.Rows[0]["UnitVol"]) * Convert.ToInt32(dtWhScan.Rows[intIndex]["Qty"]);
                        if (dtRec.Rows[0]["DimensionFlag"] != null)
                        {
                            if (dtRec.Rows[0]["DimensionFlag"].ToString() == "1")
                            {
                                dtImgr2.Rows[dtImgr2.Rows.Count - 1]["PackingQty"] = dtWhScan.Rows[intIndex]["Qty"];
                                dtImgr2.Rows[dtImgr2.Rows.Count - 1]["WholeQty"]   = Convert.ToInt32(dtWhScan.Rows[intIndex]["Qty"]) * Convert.ToInt32(dtRec.Rows[0]["PackingPackageSize"]);
                                dtImgr2.Rows[dtImgr2.Rows.Count - 1]["LooseQty"]   = Convert.ToInt32(dtImgr2.Rows[dtImgr2.Rows.Count - 1]["WholeQty"]) * Convert.ToInt32(dtRec.Rows[0]["WholePackageSize"]);
                            }
                            if (dtRec.Rows[0]["DimensionFlag"].ToString() == "2")
                            {
                                dtImgr2.Rows[dtImgr2.Rows.Count - 1]["WholeQty"] = dtWhScan.Rows[intIndex]["Qty"];
                                dtImgr2.Rows[dtImgr2.Rows.Count - 1]["LooseQty"] = Convert.ToInt32(dtImgr2.Rows[dtImgr2.Rows.Count - 1]["WholeQty"]) * Convert.ToInt32(dtRec.Rows[0]["WholePackageSize"]);
                            }
                            if (dtRec.Rows[0]["DimensionFlag"].ToString() == "3")
                            {
                                dtImgr2.Rows[dtImgr2.Rows.Count - 1]["LooseQty"] = dtWhScan.Rows[intIndex]["Qty"];
                            }
                        }
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["DimensionFlag"] = dtRec.Rows[0]["DimensionFlag"];
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["StoreNo"]       = dtWhScan.Rows[intIndex]["StoreNo"];
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["CustomerCode"]  = dtWhScan.Rows[intIndex]["CustomerCode"];
                        dtImgr2.Rows[dtImgr2.Rows.Count - 1]["WarehouseCode"] = dtWhScan.Rows[intIndex]["WarehouseCode"];
                        saveImsn1SerialNo(Modfunction.CheckNull(dtImgr1.Rows[0]["GoodsReceiptNoteNo"]), Convert.ToInt32(dtImgr2.Rows[dtImgr2.Rows.Count - 1]["LineItemNo"]), Modfunction.CheckNull(dtWhScan.Rows[intIndex]["SerialNo"]), true);
                    }
                }
                if (dtImgr2 != null && dtImgr2.Rows.Count > 0)
                {
                    intSaveResult = InsertTableRecordByDatatable("Imgr2", dtImgr2);
                    if (intSaveResult == -1)
                    {
                        return("Confirm unsuccess.");
                    }
                }
            }
            else
            {
                Result = "Confirm Unsuccess.";
            }
            return(Result);
        }
Ejemplo n.º 14
0
        private string SaveImit(DataTable dtWhScan, Boolean blnSameCustomer)
        {
            string    Result = "";
            DataTable dtRec;
            DataTable dtImit = GetSQLCommandReturnDT("Select Top 0 from imit1");

            if (dtImit != null)
            {
                dtImit.Rows.Add(dtImit.NewRow());
                if (blnSameCustomer)
                {
                    dtImit.Rows[0]["CustomerCode"] = dtWhScan.Rows[0]["ProductCustomerCode"];
                }
                dtImit.Rows[0]["TransferDateTime"]    = DateTime.Today;
                dtImit.Rows[0]["CreateBy"]            = dtWhScan.Rows[0]["ConfirmBy"];
                dtImit.Rows[0]["UpdateBy"]            = dtWhScan.Rows[0]["ConfirmBy"];
                dtImit.Rows[0]["WorkStation"]         = "PDADriver_" + dtWhScan.Rows[0]["ConfirmBy"].ToString();
                dtImit.Rows[0]["GoodsTransferNoteNo"] = CreateGoodsReceiptNo(dtImit, "Imit");
                if (dtImit.Rows[0]["GoodsTransferNoteNo"] == null || dtImit.Rows[0]["GoodsTransferNoteNo"].ToString() == "")
                {
                    dtRec = GetSQLCommandReturnDT("Select NextGoodsTransferNo From Impa1");
                    dtImit.Rows[0]["GoodsTransferNoteNo"] = Modfunction.CheckNull(dtRec.Rows[0][0]);
                    string strNewNextGoodsTransferNo = CheckUpdateFieldLength(Modfunction.CheckNull(dtRec.Rows[0][0])).ToString();
                    GetSQLCommandReturnInt("Update Impa1 set NextGoodsTransferNo = '" + Modfunction.SQLSafe(strNewNextGoodsTransferNo) + "'");
                }
                int intSaveResult = InsertTableRecordByDatatable("Imit1", dtImit);
                if (intSaveResult == -1)
                {
                    return("Confirm unsuccess.");
                }
                dtRec = GetSQLCommandReturnDT("Select Max(TrxNo) from Imit1 Where WorkStation = " + Modfunction.SQLSafeValue(dtImit.Rows[0]["WorkStation"]) + " AND CreateBy = " + Modfunction.SQLSafeValue(dtImit.Rows[0]["CreateBy"]));
                if (dtRec != null && dtRec.Rows.Count > 0)
                {
                    int       intTrxNo = Convert.ToInt32(dtRec.Rows[0][0]);
                    DataTable dtImit2  = GetSQLCommandReturnDT("Select Top 0 from Imit2 ");
                    dtImit2.Rows.Clear();
                    for (int intIndex = 0; intIndex < dtWhScan.Rows.Count; intIndex++)
                    {
                        dtRec = GetSQLCommandReturnDT("Select * from Impr1 Where TrxNo = " + Convert.ToInt32(dtWhScan.Rows[intIndex]["ProductTrxNo"]).ToString());
                        if (dtRec != null && dtRec.Rows.Count > 0)
                        {
                            dtImit2.Rows.Add(dtImit2.NewRow());
                            dtImit2.Rows[dtImit2.Rows.Count - 1]["TrxNo"]        = intTrxNo;
                            dtImit2.Rows[dtImit2.Rows.Count - 1]["LineItemNo"]   = dtImit2.Rows.Count;
                            dtImit2.Rows[dtImit2.Rows.Count - 1]["ProductTrxNo"] = dtRec.Rows[0]["TrxNo"];
                            dtImit2.Rows[dtImit2.Rows.Count - 1]["Weight"]       = Convert.ToDecimal(dtRec.Rows[0]["UnitWt"]) * Convert.ToInt32(dtWhScan.Rows[intIndex]["Qty"]);
                            dtImit2.Rows[dtImit2.Rows.Count - 1]["Volume"]       = Convert.ToDecimal(dtRec.Rows[0]["UnitVol"]) * Convert.ToInt32(dtWhScan.Rows[intIndex]["Qty"]);
                            if (dtRec.Rows[0]["DimensionFlag"] != null)
                            {
                                if (dtRec.Rows[0]["DimensionFlag"].ToString() == "1")
                                {
                                    dtImit2.Rows[dtImit2.Rows.Count - 1]["PackingQty"] = dtWhScan.Rows[intIndex]["Qty"];
                                    dtImit2.Rows[dtImit2.Rows.Count - 1]["WholeQty"]   = Convert.ToInt32(dtWhScan.Rows[intIndex]["Qty"]) * Convert.ToInt32(dtRec.Rows[0]["PackingPackageSize"]);
                                    dtImit2.Rows[dtImit2.Rows.Count - 1]["LooseQty"]   = Convert.ToInt32(dtImit2.Rows[dtImit2.Rows.Count - 1]["WholeQty"]) * Convert.ToInt32(dtRec.Rows[0]["WholePackageSize"]);
                                }
                                if (dtRec.Rows[0]["DimensionFlag"].ToString() == "2")
                                {
                                    dtImit2.Rows[dtImit2.Rows.Count - 1]["WholeQty"] = dtWhScan.Rows[intIndex]["Qty"];
                                    dtImit2.Rows[dtImit2.Rows.Count - 1]["LooseQty"] = Convert.ToInt32(dtImit2.Rows[dtImit2.Rows.Count - 1]["WholeQty"]) * Convert.ToInt32(dtRec.Rows[0]["WholePackageSize"]);
                                }
                                if (dtRec.Rows[0]["DimensionFlag"].ToString() == "3")
                                {
                                    dtImit2.Rows[dtImit2.Rows.Count - 1]["LooseQty"] = dtWhScan.Rows[intIndex]["Qty"];
                                }
                            }
                            dtImit2.Rows[dtImit2.Rows.Count - 1]["NewStoreNo"]       = dtWhScan.Rows[intIndex]["StoreNo"];
                            dtImit2.Rows[dtImit2.Rows.Count - 1]["NewWarehouseCode"] = dtWhScan.Rows[intIndex]["WarehouseCode"];
                            dtImit2.Rows[dtImit2.Rows.Count - 1]["StoreNo"]          = dtWhScan.Rows[intIndex]["OldStoreNo"];
                            dtImit2.Rows[dtImit2.Rows.Count - 1]["WarehouseCode"]    = dtWhScan.Rows[intIndex]["OldWarehouseCode"];
                        }
                    }
                    if (dtImit2 != null && dtImit2.Rows.Count > 0)
                    {
                        intSaveResult = InsertTableRecordByDatatable("Imit2", dtImit2);
                        if (intSaveResult == -1)
                        {
                            return("Confirm unsuccess.");
                        }
                    }
                }
                else
                {
                    Result = "Confirm Unsuccess.";
                }
                return(Result);
            }
            return(Result);
        }
Ejemplo n.º 15
0
        public int Comfirm_Picking_Imgi3(Imgi request)
        {
            int Result = -1;

            try
            {
                if (request.TrxNo != null && request.TrxNo.Trim() != "")
                {
                    string[] LineItemNoList = request.LineItemNoList.Split(',');

                    string [] ProductCodeList        = request.ProductCodeList.Split(',');
                    string[]  QtyList                = request.QtyList.Split(',');
                    string[]  PackingNoList          = request.PackingNoList.Split(',');
                    string[]  ProductDescriptionList = request.ProductDescriptionList.Split(',');
                    string[]  ProductTrxNoList       = request.ProductTrxNoList.Split(',');



                    using (var db = DbConnectionFactory.OpenDbConnection("WMS"))
                    {
                        string strPackingListDone = "";
                        string strCurrentPackingNo = "";
                        int    PackingQty = 0, WholeQty = 0, LooseQty = 0;
                        for (int i = 1; i < LineItemNoList.Length; i++)
                        {
                            if (strPackingListDone != "" && strPackingListDone.IndexOf(PackingNoList[i] + ',' + ProductCodeList[i]) > 0)
                            {
                                continue;
                            }
                            strCurrentPackingNo = PackingNoList[i] + ',' + ProductCodeList[i];
                            int intQty = int.Parse(QtyList[i]);
                            for (int j = i + 1; j < LineItemNoList.Length; j++)
                            {
                                if (strCurrentPackingNo == PackingNoList[j] + ',' + ProductCodeList[j])
                                {
                                    intQty = intQty + int.Parse(QtyList[j]);
                                }
                            }

                            if (request.DimensionFlag != null && request.DimensionFlag != "")
                            {
                                switch (request.DimensionFlag)
                                {
                                case "1":
                                    PackingQty = intQty;
                                    break;

                                case "2":
                                    WholeQty = intQty;
                                    break;

                                case "3":
                                    LooseQty = intQty;
                                    break;
                                }
                            }
                            int intMaxLineItemNo = 1;

                            List <Imgi3> list1 = db.Select <Imgi3>("Select Max(LineItemNo) LineItemNo from Imgi3 Where TrxNo = " + Modfunction.SQLSafeValue(request.TrxNo));
                            if (list1 != null)
                            {
                                if (list1[0].LineItemNo > 0)
                                {
                                    intMaxLineItemNo = list1[0].LineItemNo + 1;
                                }
                            }
                            db.ExecuteSql("insert into imgi3 (TrxNo, LineItemNo, PackingNo,ProductTrxNo, ProductDescription,PackingQty, WholeQty, LooseQty,Volume) values (" +
                                          Modfunction.SQLSafe(request.TrxNo) + "," + intMaxLineItemNo + "," + Modfunction.SQLSafeValue(PackingNoList[i].ToString()) + "," + int.Parse(ProductTrxNoList[i].ToString()) + " ," + Modfunction.SQLSafeValue(ProductDescriptionList[i].ToString()) + "," + PackingQty + "," + WholeQty + "," + LooseQty + " ,0 )");



                            strPackingListDone = strPackingListDone + ',' + strCurrentPackingNo;
                        }
                        //    string UpdateNewFlag = "N";
                        //    if (request.NewFlagList == null || request.NewFlagList.Trim() == "")
                        //    {
                        //        Result = db.SqlScalar<int>("EXEC spi_Imgr2_Mobile @TrxNo,@LineItemNo,@NewFlag,@DimensionQty,@QtyRemark,@DimensionFlag,@StoreNo,@UpdateBy", new { TrxNo = int.Parse(request.TrxNo), LineItemNo = int.Parse(request.LineItemNoList), NewFlag = UpdateNewFlag, DimensionQty = int.Parse(request.DimensionQtyList), QtyRemark = request.QtyRemarkList, DimensionFlag = request.DimensionFlagList, StoreNo = request.StoreNoList, UpdateBy = request.UserID });
                        //    }
                        //    else
                        //    {
                        //        for (int i = 0; i < DimensionFlagDetail.Length; i++)
                        //        {
                        //            UpdateNewFlag = NewFlagDetail[i];
                        //            if (UpdateNewFlag != "Y")
                        //            { UpdateNewFlag = "N"; }
                        //            Result = db.SqlScalar<int>("EXEC spi_Imgr2_Mobile @TrxNo,@LineItemNo,@NewFlag,@DimensionQty,@QtyRemark,@DimensionFlag,@StoreNo,@UpdateBy", new { TrxNo = int.Parse(request.TrxNo), LineItemNo = int.Parse(LineItemNoDetail[i]), NewFlag = UpdateNewFlag, DimensionQty = DimensionQtyDetail[i], QtyRemark = QtyRemarkDetail[i], DimensionFlag = DimensionFlagDetail[i], StoreNo = StoreNoDetail[i], UpdateBy = request.UserID });
                        //        }
                        //    }
                        //    Result = db.SqlScalar<int>("EXEC spi_Imgr_Confirm @TrxNo,@UpdateBy", new { TrxNo = int.Parse(request.TrxNo), UpdateBy = request.UserID });
                        //    if (Result != -1)
                        //    {
                        //        List<Imgr2_Receipt> Result1 = null;
                        //        Result1 = db.Select<Imgr2_Receipt>(
                        //                                "select Imgr1.GoodsReceiptNoteNo,Imgr1.CustomerCode,Imgr2.LineItemNo,Imgr1.TrxNo from imgr1 join imgr2 on imgr1.TrxNo =imgr2.TrxNo where Imgr1.TrxNo =  '" + request.TrxNo + "' "
                        //                );
                        //        if (Result1 != null && Result1.Count > 0)
                        //        {
                        //            for (int i = 0; i < Result1.Count; i++)
                        //            {
                        //                Result = db.SqlScalar<int>("Update Imgr2 Set MovementTrxNo=(Select top 1 TrxNo From Impm1 Where BatchNo=@GoodsReceiptNoteNo And BatchLineItemNo=@BatchLineItemNo And CustomerCode=@CustomerCode) Where TrxNo=@TrxNo  And LineItemNo=@LineItemNo", new { GoodsReceiptNoteNo = Result1[i].GoodsReceiptNoteNo, BatchLineItemNo = Result1[i].LineItemNo, CustomerCode = Result1[i].CustomerCode, TrxNo = int.Parse(request.TrxNo), LineItemNo = Result1[i].LineItemNo });
                        //            }
                        //        }
                        //    }
                    }
                }
            }
            catch { throw; }
            return(Result);
        }