Ejemplo n.º 1
0
        public static Model.mdlResultList InsertCustomerImageType(List <Model.mdlCustomerImageType> lCustomerImageType)
        {
            var mdlResultList = new List <Model.mdlResult>();

            var mdlResult = new Model.mdlResult();



            mdlResult.Result = Manager.DataFacade.DTSQLListInsert(lCustomerImageType, "CustomerImageType");
            if (mdlResult.Result == "1")
            {
            }
            else
            {
                string ResultSubstring;

                if (mdlResult.Result.Length > 500)
                {
                    ResultSubstring = mdlResult.Result.Substring(0, 500);

                    mdlResult.Result = ResultSubstring;
                }
            }

            mdlResultList.Add(mdlResult);



            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 2
0
        public static Model.mdlResultList InsertPOSMStock(List <Model.mdlPOSMStock> lPOSMStockParam)
        {
            var mdlResultList = new List <Model.mdlResult>();

            var mdlResult = new Model.mdlResult();



            mdlResult.Result = Manager.DataFacade.DTSQLListInsert(lPOSMStockParam, "POSMStock");
            if (mdlResult.Result == "1")
            {
            }
            else
            {
                string ResultSubstring;

                if (mdlResult.Result.Length > 500)
                {
                    ResultSubstring = mdlResult.Result.Substring(0, 500);

                    mdlResult.Result = ResultSubstring;
                }
            }

            mdlResultList.Add(mdlResult);



            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
        public static Model.mdlResultList InsertCompetitorActivityVisit(List <Model.mdlCompetitorActivityVisit> lCompetitorActivityVisitParam)
        {
            var mdlResultList = new List <Model.mdlResult>();

            var mdlResult = new Model.mdlResult();



            mdlResult.Result = Manager.DataFacade.DTSQLListInsert(lCompetitorActivityVisitParam, "CompetitorActivityVisit");
            if (mdlResult.Result == "1")
            {
            }
            else
            {
                string ResultSubstring;

                if (mdlResult.Result.Length > 500)
                {
                    ResultSubstring = mdlResult.Result.Substring(0, 500);

                    mdlResult.Result = ResultSubstring;
                }
            }

            mdlResultList.Add(mdlResult);



            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 4
0
        public static Model.mdlResultList InsertLogVisit(List <Model.mdlLogVisitParam> lParamlist)
        {
            var mdlResultList = new List <Model.mdlResult>();

            foreach (var lParam in lParamlist)
            {
                var mdlResult = new Model.mdlResult();



                List <SqlParameter> sp = new List <SqlParameter>()
                {
                    new SqlParameter()
                    {
                        ParameterName = "@VisitID", SqlDbType = SqlDbType.NVarChar, Value = lParam.VisitID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@CustomerID", SqlDbType = SqlDbType.NVarChar, Value = lParam.CustomerID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Date", SqlDbType = SqlDbType.NVarChar, Value = lParam.Date
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Type", SqlDbType = SqlDbType.NVarChar, Value = lParam.Type
                    },
                };

                string query = @"INSERT INTO LogVisit (VisitID, CustomerID, Date, Type) " +
                               "VALUES (@VisitID, @CustomerID, @Date, @Type) ";    //004

                mdlResult.Result = Manager.DataFacade.DTSQLVoidCommand(query, sp); //010

                if (mdlResult.Result == "1")
                {
                }
                else
                {
                    string ResultSubstring;

                    if (mdlResult.Result.Length > 500)
                    {
                        ResultSubstring = mdlResult.Result.Substring(0, 500);

                        mdlResult.Result = ResultSubstring;
                    }
                }

                mdlResultList.Add(mdlResult);
            }


            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 5
0
        public static Model.mdlResultList UploadInsertDailyCost(List <Model.mdlDailyCostParam> lParamlist, TransactionScope scope)
        {
            var mdlResultList = new List <Model.mdlResult>();

            var mdlResult = new Model.mdlResult();


            bool lCheckDailyCostID = CheckbyDailyCostID(lParamlist.FirstOrDefault().CostID);

            if (lCheckDailyCostID == false)
            {
                mdlResult.Result = "|| DailyCostID : " + lParamlist.FirstOrDefault().DailyCostID + " " + "|| IDExist ||";
                mdlResultList.Add(mdlResult);
            }
            else
            {
                mdlResult.Result = Manager.DataFacade.DTSQLListInsert(lParamlist, "DailyCost");


                if (mdlResult.Result == "1")
                {
                }
                else
                {
                    string ResultSubstring;


                    if (mdlResult.Result.Length > 500)
                    {
                        ResultSubstring = mdlResult.Result.Substring(0, 500);

                        mdlResult.Result = ResultSubstring;
                    }

                    scope.Dispose();
                }


                mdlResultList.Add(mdlResult);
            }


            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 6
0
        public static Model.mdlResultList InsertCustomerImage(List <Model.mdlCustomerImageParam> lParamlist)
        {
            var      mdlResultList   = new List <Model.mdlResult>();
            string   UploadImagePath = ConfigurationManager.AppSettings["imagePath"];
            DateTime dateTime        = DateTime.UtcNow.Date;
            string   day             = dateTime.ToString("dd");
            string   month           = dateTime.ToString("MM");
            string   year            = dateTime.ToString("yyyy");

            foreach (var lParam in lParamlist)
            {
                var mdlResult = new Model.mdlResult();

                bool lCheckImageID = CheckbyCustomerImageID(lParam.ImageID);
                if (lCheckImageID == false)
                {
                    DeleteCustomerImage(lParam.ImageID);
                    //mdlResult.Result = "|| ImageID : " + lParam.ImageID + " " + "|| IDExist ||"; //008
                    //mdlResultList.Add(mdlResult);
                }

                //WRITE IMAGE TO SPECIFIC FOLDER
                //byte[] data = System.Convert.FromBase64String(lParam.ImageBase64);

                //System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
                //System.Drawing.Image img = System.Drawing.Image.FromStream(ms);

                //string url = "C:\\inetpub\\wwwroot\\FABER_Transport\\Images\\CustomerImage\\" + lParam.ImageType + "\\" + lParam.ImageID + ".jpg";
                //File.WriteAllBytes(url, data);
                string newUploadImagePath = UploadImagePath.Replace("//", "\\") + year + "\\" + month + "\\" + day + "\\" + lParam.ImageBase64;
                if (lParam.Longitude == null)
                {
                    lParam.Longitude = "0";
                }
                if (lParam.Latitude == null)
                {
                    lParam.Latitude = "0";
                }

                List <SqlParameter> sp = new List <SqlParameter>();

                sp = new List <SqlParameter>()
                {
                    new SqlParameter()
                    {
                        ParameterName = "@ImageID", SqlDbType = SqlDbType.NVarChar, Value = lParam.ImageID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@ImageDate", SqlDbType = SqlDbType.NVarChar, Value = lParam.ImageDate
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@ImageBase64", SqlDbType = SqlDbType.NVarChar, Value = lParam.ImageBase64
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@ImageType", SqlDbType = SqlDbType.NVarChar, Value = lParam.ImageType
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@CustomerID", SqlDbType = SqlDbType.NVarChar, Value = lParam.CustomerID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@WarehouseID", SqlDbType = SqlDbType.NVarChar, Value = lParam.WarehouseID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@DocNumber", SqlDbType = SqlDbType.NVarChar, Value = lParam.DocNumber
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@VisitID", SqlDbType = SqlDbType.NVarChar, Value = lParam.VisitID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@ImagePath", SqlDbType = SqlDbType.NVarChar, Value = ""
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Longitude", SqlDbType = SqlDbType.NVarChar, Value = lParam.Longitude
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Latitude", SqlDbType = SqlDbType.NVarChar, Value = lParam.Latitude
                    }
                };


                string query = @"INSERT INTO CustomerImage (ImageID, ImageDate, ImageBase64, ImageType, CustomerID,WarehouseID, DocNumber, VisitID, ImagePath, Longitude, Latitude) " +
                               "VALUES (@ImageID, @ImageDate, @ImageBase64, @ImageType, @CustomerID,@WarehouseID, @DocNumber, @VisitID, @ImagePath, @Longitude, @Latitude) "; //004

                mdlResult.Result = Manager.DataFacade.DTSQLVoidCommand(query, sp);                                                                                            //010

                if (mdlResult.Result == "1")
                {
                }
                else
                {
                    string ResultSubstring;

                    if (mdlResult.Result.Length > 500)
                    {
                        ResultSubstring = mdlResult.Result.Substring(0, 500);

                        mdlResult.Result = ResultSubstring;
                    }
                }

                mdlResultList.Add(mdlResult);
            }

            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 7
0
        public static Core.Model.mdlResultList UploadJson(Core.Model.mdlUploadJsonParam lParamlist)
        {
            var mdlResultList = new Model.mdlResultList();
            var listResult    = new List <Model.mdlResult>();
            var mdlResult     = new Model.mdlResult();

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    int err = 0;
                    mdlResultList = DeliveryOrderFacade.UpdateDeliveryOrder(lParamlist.UploadJson.ListDeliveryOrder);
                    mdlResultList = DeliveryOrderFacade.UpdateDeliveryOrderDetail(lParamlist.UploadJson.ListDeliveryOrderDetail);
                    mdlResultList = VisitFacade.InsertVisit(lParamlist.UploadJson.ListVisit);
                    if (mdlResultList.ResultList.FirstOrDefault().Result.Contains("IDExist") || mdlResultList.ResultList.FirstOrDefault().Result == "0")
                    {
                        err = 1;
                    }
                    mdlResultList = VisitFacade.InsertVisitDetail(lParamlist.UploadJson.ListVisitDetail);
                    if (mdlResultList.ResultList.FirstOrDefault().Result.Contains("IDExist") || mdlResultList.ResultList.FirstOrDefault().Result == "0")
                    {
                        err = 1;
                    }
                    mdlResultList = CostFacade.InsertDailyCost(lParamlist.UploadJson.ListCost);
                    if (mdlResultList.ResultList.FirstOrDefault().Result.Contains("IDExist") || mdlResultList.ResultList.FirstOrDefault().Result == "0")
                    {
                        err = 1;
                    }
                    mdlResultList = CustomerImageFacade.InsertCustomerImage(lParamlist.UploadJson.ListCustomerImage);
                    if (mdlResultList.ResultList.FirstOrDefault().Result.Contains("IDExist") || mdlResultList.ResultList.FirstOrDefault().Result == "0")
                    {
                        err = 1;
                    }
                    mdlResultList = LogVisitFacade.InsertLogVisit(lParamlist.UploadJson.ListLogVisit);
                    if (mdlResultList.ResultList.FirstOrDefault().Result.Contains("IDExist") || mdlResultList.ResultList.FirstOrDefault().Result == "0")
                    {
                        err = 1;
                    }
                    if (err == 0)
                    {
                        mdlResult.Result = "1";
                        scope.Complete();
                    }
                    else
                    {
                        mdlResult.Result = "0";
                    }
                }

                listResult.Add(mdlResult);
                mdlResultList.ResultList = listResult;

                return(mdlResultList);
            }
            catch (TransactionAbortedException ex)
            {
                mdlResult.Result = "0";
                listResult.Add(mdlResult);
                mdlResultList.ResultList = listResult;

                return(mdlResultList);
            }
        }
Ejemplo n.º 8
0
        public static Model.mdlResultList InsertDailyCost(List <Model.mdlDailyCostParam> lParamlist)
        {
            var mdlResultList = new List <Model.mdlResult>();

            var mdlResult = new Model.mdlResult();


            //bool lCheckDailyCostID = CheckbyDailyCostID(lParamlist.FirstOrDefault().DailyCostID);

            foreach (var cost in lParamlist)
            {
                bool lCheckDailyCostID = CheckbyDailyCostID(cost.DailyCostID);



                if (lCheckDailyCostID == false)
                {
                    mdlResult.Result = "|| DailyCostID : " + lParamlist.FirstOrDefault().DailyCostID + " " + "|| IDExist ||";
                    mdlResultList.Add(mdlResult);
                }
                else
                {
                    cost.CreatedBy   = cost.EmployeeID;
                    cost.CreatedDate = DateTime.Now;

                    cost.LastUpdatedBy   = cost.EmployeeID;
                    cost.LastUpdatedDate = DateTime.Now;

                    var listCost = new List <Model.mdlDailyCostParam>();
                    listCost.Add(cost);
                    mdlResult.Result = Manager.DataFacade.DTSQLListInsert(listCost, "DailyCost");


                    if (mdlResult.Result == "1")
                    {
                    }
                    else
                    {
                        string ResultSubstring;


                        if (mdlResult.Result.Length > 500)
                        {
                            ResultSubstring = mdlResult.Result.Substring(0, 500);

                            mdlResult.Result = ResultSubstring;
                        }
                    }


                    mdlResultList.Add(mdlResult);
                }
            }



            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 9
0
        public static Model.mdlResultList UpdateReturOrder(List <Model.mdlReturOrderParam> lParamlist)
        {
            var mdlResultList = new List <Model.mdlResult>();

            foreach (var lParam in lParamlist)
            {
                if (lParam.ReturStatus == "")
                {
                    var mdlResult = new Model.mdlResult();
                    mdlResult.Result = "|| " + "Update Retur Order : " + lParam.ReturNumber + " and CustomerID  : " + lParam.CustomerID + " || " + " Cancelled";
                    mdlResultList.Add(mdlResult);
                }
                else
                {
                    var mdlResult          = new Model.mdlResult();
                    List <SqlParameter> sp = new List <SqlParameter>()
                    {
                        new SqlParameter()
                        {
                            ParameterName = "@ReturNumber", SqlDbType = SqlDbType.NVarChar, Value = lParam.ReturNumber
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@CustomerID", SqlDbType = SqlDbType.NVarChar, Value = lParam.CustomerID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ReturStatus", SqlDbType = SqlDbType.NVarChar, Value = lParam.ReturStatus
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ReturDate", SqlDbType = SqlDbType.DateTime, Value = lParam.ReturDate
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Description", SqlDbType = SqlDbType.NVarChar, Value = lParam.Description
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Signature", SqlDbType = SqlDbType.NVarChar, Value = lParam.Signature
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@IsPrint", SqlDbType = SqlDbType.NVarChar, Value = lParam.IsPrint
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Remark", SqlDbType = SqlDbType.NVarChar, Value = lParam.Remark
                        },                                                                                                       //003
                        new SqlParameter()
                        {
                            ParameterName = "@EmployeeID", SqlDbType = SqlDbType.NVarChar, Value = lParam.EmployeeID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@VisitID", SqlDbType = SqlDbType.NVarChar, Value = lParam.VisitID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@BranchID", SqlDbType = SqlDbType.NVarChar, Value = lParam.BranchID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ReceivedDate", SqlDbType = SqlDbType.DateTime, Value = lParam.ReceivedDate
                        }
                    };


                    string query = @"UPDATE ReturOrder SET
                                            CustomerID = @CustomerID,
                                            ReturStatus = @ReturStatus,
                                            ReturDate = @ReturDate,
                                            Description = @Description,
                                            Signature = @Signature,
                                            IsPrint = @IsPrint,
                                            Remark = @Remark,
                                            EmployeeID = @EmployeeID,
                                            VisitID = @VisitID,
                                            BranchID = @BranchID, 
                                            ReceivedDate = @ReceivedDate
                                        WHERE ReturNumber = @ReturNumber ";


                    mdlResult.Result = "|| " + "Update Retur Order : " + lParam.ReturNumber + " and CustomerID  : " + lParam.CustomerID + " || " + Manager.DataFacade.DTSQLVoidCommand(query, sp);



                    if (mdlResult.Result.Contains("SQLSuccess") == true)
                    {
                    }
                    else
                    {
                        string ResultSubstring;


                        if (mdlResult.Result.Length > 500)
                        {
                            ResultSubstring = mdlResult.Result.Substring(0, 500);

                            mdlResult.Result = ResultSubstring;
                        }
                    }


                    mdlResultList.Add(mdlResult);
                }
            }

            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;

            return(mdlResultListnew);
        }
Ejemplo n.º 10
0
        public static Model.mdlResultList InsertReturOrderDetail(List <Model.mdlReturOrderDetailParam> lParamlist)
        {
            var mdlResultList = new List <Model.mdlResult>();

            foreach (var lParam in lParamlist)
            {
                if (lParam.Quantity == "" || lParam.Quantity == null)
                {
                    lParam.Quantity = "0";
                }

                var mdlResult = new Model.mdlResult();

                bool lCheckReturNumberAndProductID = CheckbyReturNumberAndProductID(lParam.ReturNumber, lParam.ProductID);
                if (lCheckReturNumberAndProductID == false)
                {
                    mdlResult.Result = " || ReturNumber : " + lParam.ReturNumber + " and ProductID : " + lParam.ProductID + " " + "|| IDExist ||";
                    mdlResultList.Add(mdlResult);
                }
                else
                {
                    List <SqlParameter> sp = new List <SqlParameter>()
                    {
                        new SqlParameter()
                        {
                            ParameterName = "@ReturNumber", SqlDbType = SqlDbType.NVarChar, Value = lParam.ReturNumber
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ProductID", SqlDbType = SqlDbType.NVarChar, Value = lParam.ProductID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@UOM", SqlDbType = SqlDbType.NVarChar, Value = lParam.UOM
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Quantity", SqlDbType = SqlDbType.Decimal, Value = lParam.Quantity
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@QuantityReal", SqlDbType = SqlDbType.Decimal, Value = lParam.QuantityReal
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ArticleNumber", SqlDbType = SqlDbType.NVarChar, Value = lParam.ArticleNumber
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ReasonID", SqlDbType = SqlDbType.NVarChar, Value = lParam.ReasonID
                        }
                    };

                    string query = @"INSERT INTO ReturOrderDetail (ReturNumber, ProductID, UOM, Quantity, QuantityReal, ArticleNumber,ReasonID) " +
                                   "VALUES (@ReturNumber, @ProductID, @UOM, @Quantity, @QuantityReal, @ArticleNumber, @ReasonID)";

                    mdlResult.Result = " || ReturNumber : " + lParam.ReturNumber + " and ProductID : " + lParam.ProductID + " || " + Manager.DataFacade.DTSQLVoidCommand(query, sp);

                    if (mdlResult.Result.Contains("SQLSuccess") == true)
                    {
                    }
                    else
                    {
                        string ResultSubstring;


                        if (mdlResult.Result.Length > 500)
                        {
                            ResultSubstring = mdlResult.Result.Substring(0, 500);

                            mdlResult.Result = ResultSubstring;
                        }
                    }

                    mdlResultList.Add(mdlResult);
                }
            }

            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 11
0
        public static Model.mdlResultList InsertReturOrder(List <Model.mdlReturOrderParam> lParamlist)
        {
            var mdlResultList = new List <Model.mdlResult>();

            foreach (var lParam in lParamlist)
            {
                var mdlResult = new Model.mdlResult();

                bool lCheckReturNumber = CheckbyReturNumber(lParam.ReturNumber);
                if (lCheckReturNumber == false)
                {
                    mdlResult.Result = " || ReturNumber : " + lParam.ReturNumber + " " + "|| IDExist ||";
                    mdlResultList.Add(mdlResult);
                }
                else
                {
                    List <SqlParameter> sp = new List <SqlParameter>()
                    {
                        new SqlParameter()
                        {
                            ParameterName = "@ReturNumber", SqlDbType = SqlDbType.NVarChar, Value = lParam.ReturNumber
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@CustomerID", SqlDbType = SqlDbType.NVarChar, Value = lParam.CustomerID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@EmployeeID", SqlDbType = SqlDbType.NVarChar, Value = lParam.EmployeeID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@VisitID", SqlDbType = SqlDbType.NVarChar, Value = lParam.VisitID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@BranchID", SqlDbType = SqlDbType.NVarChar, Value = lParam.BranchID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ReturDate", SqlDbType = SqlDbType.Date, Value = lParam.ReturDate
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ReturStatus", SqlDbType = SqlDbType.NVarChar, Value = lParam.ReturStatus
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Description", SqlDbType = SqlDbType.NVarChar, Value = lParam.Description
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Signature", SqlDbType = SqlDbType.NVarChar, Value = lParam.Signature
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@IsPrint", SqlDbType = SqlDbType.NVarChar, Value = lParam.IsPrint
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Remark", SqlDbType = SqlDbType.NVarChar, Value = lParam.Remark
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ReceivedDate", SqlDbType = SqlDbType.DateTime, Value = lParam.ReceivedDate
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@IsNewRetur", SqlDbType = SqlDbType.NVarChar, Value = lParam.IsNewRetur
                        }
                    };

                    string query = @"INSERT INTO ReturOrder (ReturNumber, CustomerID, EmployeeID, VisitID, BranchID, ReturDate, ReturStatus, Description, Signature, IsPrint, Remark, ReceivedDate, IsNewRetur) " +
                                   "VALUES (@ReturNumber, @CustomerID, @EmployeeID, @VisitID, @BranchID, @ReturDate, @ReturStatus, @Description, @Signature, @IsPrint, @Remark, @ReceivedDate, @IsNewRetur)";

                    mdlResult.Result = "|| " + "Insert Retur Number " + lParam.ReturNumber + " || " + Manager.DataFacade.DTSQLVoidCommand(query, sp);

                    if (mdlResult.Result.Contains("SQLSuccess") == true)
                    {
                    }
                    else
                    {
                        string ResultSubstring;


                        if (mdlResult.Result.Length > 500)
                        {
                            ResultSubstring = mdlResult.Result.Substring(0, 500);

                            mdlResult.Result = ResultSubstring;
                        }
                    }

                    mdlResultList.Add(mdlResult);
                }
            }

            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 12
0
        public static Model.mdlResultList UpdateReturOrderDetail(List <Model.mdlReturOrderDetailParam> lParamlist)
        {
            var mdlResultList = new List <Model.mdlResult>();

            foreach (var lParam in lParamlist)
            {
                if (lParam.QuantityReal == "0" || lParam.QuantityReal == "")
                {
                    var mdlResult = new Model.mdlResult();
                    mdlResult.Result = "|| " + "Update Retur Order Detail : " + lParam.ReturNumber + " and ProductID  : " + lParam.ProductID + " || " + " Cancelled";
                    mdlResultList.Add(mdlResult);
                }
                else
                {
                    var mdlResult          = new Model.mdlResult();
                    List <SqlParameter> sp = new List <SqlParameter>()
                    {
                        new SqlParameter()
                        {
                            ParameterName = "@ReturNumber", SqlDbType = SqlDbType.NVarChar, Value = lParam.ReturNumber
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ProductID", SqlDbType = SqlDbType.NVarChar, Value = lParam.ProductID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@UOM", SqlDbType = SqlDbType.NVarChar, Value = lParam.UOM
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Quantity", SqlDbType = SqlDbType.Decimal, Value = lParam.Quantity
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@QuantityReal", SqlDbType = SqlDbType.Decimal, Value = lParam.QuantityReal
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ArticleNumber", SqlDbType = SqlDbType.NVarChar, Value = lParam.ArticleNumber
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ReasonID", SqlDbType = SqlDbType.NVarChar, Value = lParam.ReasonID
                        }
                    };


                    string query = @"UPDATE ReturOrderDetail SET
                                                UOM = @UOM,
                                                Quantity=@Quantity,
                                                QuantityReal=@QuantityReal,
                                                ArticleNumber=@ArticleNumber,
                                                ReasonID = @ReasonID
                                            WHERE  ReturNumber = @ReturNumber AND ProductID = @ProductID";


                    mdlResult.Result = "|| " + "Update Retur Order " + lParam.ReturNumber + " || " + lParam.ProductID + " || " + Manager.DataFacade.DTSQLVoidCommand(query, sp);


                    if (mdlResult.Result.Contains("SQLSuccess") == true)
                    {
                    }
                    else
                    {
                        string ResultSubstring;


                        if (mdlResult.Result.Length > 500)
                        {
                            ResultSubstring = mdlResult.Result.Substring(0, 500);

                            mdlResult.Result = ResultSubstring;
                        }
                    }


                    mdlResultList.Add(mdlResult);
                }
            }

            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;

            return(mdlResultListnew);
        }
Ejemplo n.º 13
0
        public static Model.mdlResultList UploadUpdateDeliveryOrderDetail(List <Model.mdlDeliveryOrderDetailParam> lDODetailParamlist, TransactionScope scope)
        {
            var mdlResultList = new List <Model.mdlResult>();

            var mdlResult = new Model.mdlResult();

            var listDODetail = new List <Model.mdlDBDeliveryOrderDetail>();

            foreach (var lDODetailParam in lDODetailParamlist)
            {
                var mdlDODetail = new Model.mdlDBDeliveryOrderDetail();
                mdlDODetail.DONumber     = lDODetailParam.DONumber;
                mdlDODetail.ProductID    = lDODetailParam.ProductID;
                mdlDODetail.UOM          = lDODetailParam.UOM;
                mdlDODetail.Quantity     = 0;
                mdlDODetail.QuantityReal = Convert.ToInt32(lDODetailParam.QuantityReal);
                mdlDODetail.ProductGroup = "";
                mdlDODetail.LotNumber    = "";
                mdlDODetail.ReasonID     = "";
                mdlDODetail.BoxID        = "";

                listDODetail.Add(mdlDODetail);
            }

            var listUpdateCol = new List <string>();

            listUpdateCol.Add("QuantityReal");


            var listOnCol = new List <string>();

            listOnCol.Add("DONumber");
            listOnCol.Add("ProductID");
            listOnCol.Add("UOM");


            mdlResult.Result = Manager.DataFacade.DTSQLListUpdate(listDODetail, "DeliveryOrderDetail", listUpdateCol, listOnCol);

            if (mdlResult.Result == "1")
            {
            }
            else
            {
                string ResultSubstring;


                if (mdlResult.Result.Length > 500)
                {
                    ResultSubstring = mdlResult.Result.Substring(0, 500);

                    mdlResult.Result = ResultSubstring;
                    //
                }
                scope.Dispose();
            }

            mdlResultList.Add(mdlResult);

            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;

            return(mdlResultListnew);
        }
Ejemplo n.º 14
0
        public static Model.mdlResultList UploadUpdateDeliveryOrder(List <Model.mdlDeliveryOrderParam> lDOParamlist, TransactionScope scope) //005,009
        {
            var mdlResultList = new List <Model.mdlResult>();

            var listDO = new List <Model.DeliveryOrder>();

            var mdlResult = new Model.mdlResult();

            foreach (var lDOParam in lDOParamlist)
            {
                var mdlDO = new Model.DeliveryOrder();
                //Have To Be Filled
                mdlDO.DONumber    = lDOParam.DONumber;
                mdlDO.CallPlanID  = lDOParam.CallPlanID;
                mdlDO.CustomerID  = lDOParam.CustomerID;
                mdlDO.WarehouseID = lDOParam.WarehouseID;
                //Have To Be Filled

                //Updated Data
                mdlDO.DOStatus     = lDOParam.DOStatus;
                mdlDO.Signature    = lDOParam.Signature;
                mdlDO.IsPrint      = Convert.ToBoolean(lDOParam.IsPrint);
                mdlDO.LastDate     = DateTime.Now;
                mdlDO.LastUpdateBy = lDOParam.EmployeeID;
                mdlDO.VisitID      = lDOParam.VisitID;
                //Updated Data


                //additional
                mdlDO.CreatedDate = DateTime.Now;
                mdlDO.DODate      = DateTime.Now;
                mdlDO.Description = "";
                mdlDO.BranchID    = lDOParam.BranchID;
                mdlDO.VehicleID   = lDOParam.VehicleID;
                mdlDO.EmployeeID  = lDOParam.EmployeeID;
                mdlDO.Remark      = "";
                mdlDO.CreatedBy   = "";
                //additional

                listDO.Add(mdlDO);
            }


            var listUpdateCol = new List <string>();

            listUpdateCol.Add("DOStatus");
            listUpdateCol.Add("Signature");
            listUpdateCol.Add("IsPrint");
            listUpdateCol.Add("LastDate");
            listUpdateCol.Add("LastUpdateBy");
            listUpdateCol.Add("VisitID");

            var listOnCol = new List <string>();

            listOnCol.Add("DONumber");
            listOnCol.Add("CallPlanID");
            listOnCol.Add("CustomerID");


            mdlResult.Result = Manager.DataFacade.DTSQLListUpdate(listDO, "DeliveryOrder", listUpdateCol, listOnCol);


            if (mdlResult.Result == "1")
            {
            }
            else
            {
                string ResultSubstring;


                if (mdlResult.Result.Length > 500)
                {
                    ResultSubstring = mdlResult.Result.Substring(0, 500);

                    mdlResult.Result = ResultSubstring;
                    //
                }
                scope.Dispose();
            }

            mdlResultList.Add(mdlResult);
            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;

            return(mdlResultListnew);
        }
Ejemplo n.º 15
0
        //BulkCopy Method
        //public static Model.mdlResultList InsertCostVisit(List<Model.mdlCostVisit> lParamlist)
        //{
        //    var mdlResultList = new List<Model.mdlResult>();

        //    var mdlResult = new Model.mdlResult();


        //    //bool lCheckDailyCostID = CheckbyDailyCostID(lParamlist.FirstOrDefault().DailyCostID);

        //    foreach (var cost in lParamlist)
        //    {
        //        bool lCheckDailyCostID = CheckCostVisitID(cost.VisitID,cost.CostID);


        //        if (lCheckDailyCostID == false)
        //        {
        //            mdlResult.Result = "|| VisitID : " + cost.VisitID + " and CostID : " + cost.CostID + " || Already Exist ||";
        //            mdlResultList.Add(mdlResult);
        //        }
        //        else
        //        {

        //            var listCost = new List<Model.mdlCostVisit>();
        //            listCost.Add(cost);
        //            mdlResult.Result = Manager.DataFacade.DTSQLListInsert(listCost, "CostVisit");


        //            if (mdlResult.Result == "1")
        //            {
        //            }
        //            else
        //            {
        //                string ResultSubstring;


        //                if (mdlResult.Result.Length > 500)
        //                {
        //                    ResultSubstring = mdlResult.Result.Substring(0, 500);

        //                    mdlResult.Result = ResultSubstring;
        //                }


        //            }


        //            mdlResultList.Add(mdlResult);
        //        }
        //    }



        //    var mdlResultListnew = new Model.mdlResultList();
        //    mdlResultListnew.ResultList = mdlResultList;
        //    return mdlResultListnew;
        //}

        //SQL INSERT METHOD
        public static Model.mdlResultList InsertCostVisit(List <Model.mdlCostVisit> lParamlist)
        {
            var mdlResultList = new List <Model.mdlResult>();

            foreach (var lParam in lParamlist)
            {
                var mdlResult = new Model.mdlResult();

                bool lCheckDailyCostID = CheckCostVisitID(lParam.VisitID, lParam.CostID);

                if (lCheckDailyCostID == false)
                {
                    mdlResult.Result = "|| VisitID : " + lParam.VisitID + " and CostID : " + lParam.CostID + " || Already Exist ||";
                    mdlResultList.Add(mdlResult);
                }
                else
                {
                    List <SqlParameter> sp = new List <SqlParameter>()
                    {
                        new SqlParameter()
                        {
                            ParameterName = "@VisitID", SqlDbType = SqlDbType.NVarChar, Value = lParam.VisitID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@CostID", SqlDbType = SqlDbType.NVarChar, Value = lParam.CostID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@BranchID", SqlDbType = SqlDbType.NVarChar, Value = lParam.BranchID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@EmployeeID", SqlDbType = SqlDbType.NVarChar, Value = lParam.EmployeeID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Value", SqlDbType = SqlDbType.NVarChar, Value = lParam.Value
                        }
                    };

                    string query = @"INSERT INTO CostVisit (VisitID, CostID, Value, EmployeeID, BranchID) " +
                                   "VALUES (@VisitID, @CostID, @Value, @EmployeeID, @BranchID) ";

                    mdlResult.Result = Manager.DataFacade.DTSQLVoidCommand(query, sp);

                    if (mdlResult.Result == "1")
                    {
                    }
                    else
                    {
                        string ResultSubstring;

                        if (mdlResult.Result.Length > 500)
                        {
                            ResultSubstring = mdlResult.Result.Substring(0, 500);

                            mdlResult.Result = ResultSubstring;
                        }
                    }

                    mdlResultList.Add(mdlResult);
                }
            }

            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 16
0
        public static Model.mdlResultList InsertTracking(Model.mdlTrackingParam lParam)
        {
            var newMdlResultList = new Model.mdlResultList();
            var mdlResultList    = new List <Model.mdlResult>();
            var mdlResult        = new Model.mdlResult();

            bool lCheckImageID = CheckbyTrackingID(lParam.TrackingID);

            if (lCheckImageID == false)
            {
                mdlResult.Result = "|| TrackingID : " + lParam.TrackingID + " " + "|| IDExist ||"; //006
            }
            else
            {
                List <SqlParameter> sp = new List <SqlParameter>()
                {
                    new SqlParameter()
                    {
                        ParameterName = "@TrackingID", SqlDbType = SqlDbType.NVarChar, Value = lParam.TrackingID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@TrackingDate", SqlDbType = SqlDbType.NVarChar, Value = lParam.TrackingDate
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@VehicleID", SqlDbType = SqlDbType.NVarChar, Value = lParam.VehicleID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@EmployeeID", SqlDbType = SqlDbType.NVarChar, Value = lParam.EmployeeID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Longitude", SqlDbType = SqlDbType.NVarChar, Value = lParam.Longitude
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Latitude", SqlDbType = SqlDbType.NVarChar, Value = lParam.Latitude
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@BranchID", SqlDbType = SqlDbType.NVarChar, Value = lParam.BranchID
                    },
                };

                string query = @"INSERT INTO LiveTracking (TrackingID, TrackingDate, VehicleID, EmployeeID, Longitude, Latitude, BranchID) " +
                               "VALUES (@TrackingID, @TrackingDate, @VehicleID, @EmployeeID, @Longitude, @Latitude, @BranchID) ";

                mdlResult.Result = "|| " + "Insert Tracking ID " + lParam.TrackingID + " || " + Manager.DataFacade.DTSQLVoidCommand(query, sp);


                if (mdlResult.Result.Contains("1") == true)
                {
                    mdlResultList.Add(mdlResult);
                }
                else
                {
                    string ResultSubstring;

                    if (mdlResult.Result.Length > 500)
                    {
                        ResultSubstring = mdlResult.Result.Substring(0, 500);

                        //mdlResult.Result = ResultSubstring;
                        mdlResultList.Add(mdlResult);
                    }
                }
            }

            newMdlResultList.ResultList = mdlResultList;

            return(newMdlResultList);
        }
Ejemplo n.º 17
0
        public static Model.mdlResultList UploadInsertCustomerImage(List <Model.mdlCustomerImageParam> lParamlist, TransactionScope scope)
        {
            var mdlResultList = new List <Model.mdlResult>();

            foreach (var lParam in lParamlist)
            {
                var mdlResult = new Model.mdlResult();

                bool lCheckImageID = CheckbyCustomerImageID(lParam.ImageID);
                if (lCheckImageID == false)
                {
                    DeleteCustomerImage(lParam.ImageID);
                    //mdlResult.Result = "|| ImageID : " + lParam.ImageID + " " + "|| IDExist ||"; //008
                    //mdlResultList.Add(mdlResult);
                }
                else
                {
                    //WRITE IMAGE TO SPECIFIC FOLDER
                    //byte[] data = System.Convert.FromBase64String(lParam.ImageBase64);

                    //System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
                    //System.Drawing.Image img = System.Drawing.Image.FromStream(ms);

                    //string url = "C:\\inetpub\\wwwroot\\FABER_Transport\\Images\\CustomerImage\\" + lParam.ImageType + "\\" + lParam.ImageID + ".jpg";
                    //File.WriteAllBytes(url, data);

                    List <SqlParameter> sp = new List <SqlParameter>()
                    {
                        new SqlParameter()
                        {
                            ParameterName = "@ImageID", SqlDbType = SqlDbType.NVarChar, Value = lParam.ImageID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ImageDate", SqlDbType = SqlDbType.NVarChar, Value = lParam.ImageDate
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ImageBase64", SqlDbType = SqlDbType.NVarChar, Value = lParam.ImageBase64
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@ImageType", SqlDbType = SqlDbType.NVarChar, Value = lParam.ImageType
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@CustomerID", SqlDbType = SqlDbType.NVarChar, Value = lParam.CustomerID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@WarehouseID", SqlDbType = SqlDbType.NVarChar, Value = lParam.WarehouseID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@DocNumber", SqlDbType = SqlDbType.NVarChar, Value = lParam.DocNumber
                        },                                                                                                           //004
                        new SqlParameter()
                        {
                            ParameterName = "@VisitID", SqlDbType = SqlDbType.NVarChar, Value = lParam.VisitID
                        },                                                                                                         //002
                        new SqlParameter()
                        {
                            ParameterName = "@ImagePath", SqlDbType = SqlDbType.NVarChar, Value = ""
                        }
                    };

                    string query = @"INSERT INTO CustomerImage (ImageID, ImageDate, ImageBase64, ImageType, CustomerID,WarehouseID, DocNumber, VisitID, ImagePath) " +
                                   "VALUES (@ImageID, @ImageDate, @ImageBase64, @ImageType, @CustomerID,@WarehouseID, @DocNumber, @VisitID, @ImagePath) "; //004

                    mdlResult.Result = Manager.DataFacade.DTSQLVoidCommand(query, sp);                                                                     //010

                    if (mdlResult.Result == "1")
                    {
                    }
                    else
                    {
                        string ResultSubstring;

                        if (mdlResult.Result.Length > 500)
                        {
                            ResultSubstring = mdlResult.Result.Substring(0, 500);

                            mdlResult.Result = ResultSubstring;
                        }
                        scope.Dispose();
                    }

                    mdlResultList.Add(mdlResult);
                }
            }

            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 18
0
        public static Model.mdlResultList UploadDeposit(List <Model.mdlDepositParam> lParamlist)
        {
            var mdlResultList = new List <Model.mdlResult>();

            foreach (var lParam in lParamlist)
            {
                var mdlResult = new Model.mdlResult();

                List <SqlParameter> sp = new List <SqlParameter>()
                {
                    //header
                    new SqlParameter()
                    {
                        ParameterName = "@DepositID", SqlDbType = SqlDbType.NVarChar, Value = lParam.DepositID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@VisitID", SqlDbType = SqlDbType.NVarChar, Value = lParam.VisitID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@EmployeeID", SqlDbType = SqlDbType.NVarChar, Value = lParam.EmployeeID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Status", SqlDbType = SqlDbType.NVarChar, Value = lParam.Status
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@ReceivedDate", SqlDbType = SqlDbType.NVarChar, Value = lParam.ReceivedDate
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Description", SqlDbType = SqlDbType.NVarChar, Value = lParam.Description
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@CustomerID", SqlDbType = SqlDbType.NVarChar, Value = lParam.CustomerID
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@CreatedBy", SqlDbType = SqlDbType.NVarChar, Value = lParam.CreatedBy
                    },
                    //new SqlParameter() {ParameterName = "@CreatedDate", SqlDbType = SqlDbType.NVarChar, Value = lParam.CreatedDate},
                    new SqlParameter()
                    {
                        ParameterName = "@LastUpdateBy", SqlDbType = SqlDbType.NVarChar, Value = lParam.LastUpdateBy
                    },
                    //new SqlParameter() {ParameterName = "@LastDate", SqlDbType = SqlDbType.NVarChar, Value = lParam.LastDate}
                    //detail
                    new SqlParameter()
                    {
                        ParameterName = "@Note", SqlDbType = SqlDbType.NVarChar, Value = lParam.Note
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Amount", SqlDbType = SqlDbType.Decimal, Value = lParam.Amount
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@Seq", SqlDbType = SqlDbType.NVarChar, Value = lParam.Seq
                    },
                    new SqlParameter()
                    {
                        ParameterName = "@DepositTypeID", SqlDbType = SqlDbType.NVarChar, Value = lParam.DepositTypeID
                    }
                };

                String query = @"BEGIN TRAN
                                    DELETE FROM [DepositDetail]
                                    WHERE DepositID = @DepositID

                                    INSERT INTO[DepositDetail] (
                                        DepositID
                                        ,Note
                                        ,Amount
                                        ,Seq
                                        ,DepositTypeID
                                    )
                                   VALUES(
                                       @DepositID
                                       ,@Note
                                       ,@Amount
                                       ,@Seq
                                       ,@DepositTypeID
                                   )

                                    UPDATE [Deposit] SET
                                        VisitID = @VisitID
                                        ,EmployeeID = @EmployeeID
                                        ,Status = @Status
                                        ,ReceivedDate = @ReceivedDate
                                        ,Description = @Description
                                        ,CustomerID = @CustomerID
                                        ,LastUpdateBy = @LastUpdateBy
                                        ,LastDate = GETDATE()
                                    WHERE DepositID = @DepositID

                                    IF @@rowcount = 0
                                    BEGIN
                                        INSERT INTO [Deposit] (
                                            DepositID
                                            ,VisitID
                                            ,EmployeeID
                                            ,Status
                                            ,ReceivedDate
                                            ,Description
                                            ,CustomerID
                                            ,CreatedBy
                                            ,CreatedDate
                                            ,IsSMS
                                        ) 
                                        VALUES (
                                            @DepositID
                                            ,@VisitID
                                            ,@EmployeeID
                                            ,@Status
                                            ,@ReceivedDate
                                            ,@Description
                                            ,@CustomerID
                                            ,@CreatedBy
                                            ,GETDATE()
                                            ,0
                                        )
                                    END
                                COMMIT TRAN";

                mdlResult.Result = Manager.DataFacade.DTSQLVoidCommand(query, sp);

                if (mdlResult.Result == "1")
                {
                    // setelah upload berhasil akan memanggil API sms gateway
                    // sebelumnya cek dahulu apakah status smsnya berhasil atau tidak
                    List <SqlParameter> sp_checkstatus = new List <SqlParameter>()
                    {
                        new SqlParameter()
                        {
                            ParameterName = "@DepositID", SqlDbType = SqlDbType.NVarChar, Value = lParam.DepositID
                        }
                    };

                    string    query_checkstatus = "SELECT IsSMS FROM DEPOSIT WHERE DepositID = @DepositID ";
                    DataTable dtCheck           = DataFacade.DTSQLCommand(query_checkstatus, sp_checkstatus);
                    int       statusSMS         = 0;
                    foreach (DataRow rowCheck in dtCheck.Rows)
                    {
                        statusSMS = Convert.ToInt32(rowCheck["IsSMS"].ToString());
                    }

                    if (statusSMS == 1)
                    {
                        // do nothing
                        mdlResult.ResultValue = "UPLOAD SUCCESS";
                    }
                    else
                    {
                        // ambil company name
                        string CompanyName            = "";
                        List <SqlParameter> spCompany = new List <SqlParameter>()
                        {
                        };

                        string    qryCompany = "SELECT * FROM Company WHERE CompanyID = 'BPR'";
                        DataTable dtCompany  = DataFacade.DTSQLCommand(qryCompany, spCompany);
                        foreach (DataRow rowCompany in dtCompany.Rows)
                        {
                            CompanyName = rowCompany["CompanyName"].ToString();
                        }

                        //default testing
                        string MsisdnSmsGateway = "82298332125";

                        //string MsisdnSmsGateway = lParam.CustomerMobilephone1;
                        string rekeningNo         = lParam.BankAccountNumber;
                        string lTime              = DateTime.Now.ToString("yyyyMMddhhmmss");
                        double value              = lParam.Amount;
                        string valueDeli          = String.Format(CultureInfo.InvariantCulture, "{0:0,0}", value);
                        string urlAPI             = ConfigurationManager.AppSettings["UrlAPISmsGateway"];
                        string UserSmsGateway     = ConfigurationManager.AppSettings["UserSmsGateway"];
                        string PasswordSmsGateway = ConfigurationManager.AppSettings["PasswordSmsGateway"];
                        string SenderIDSmsGateway = ConfigurationManager.AppSettings["SenderIDSmsGateway"];
                        string MessageSmsGateway  = CompanyName + "\n" +
                                                    "SUKSES No=" + lParam.DepositID + "\n" +
                                                    "Setoran" + "\n" +
                                                    "Rek=" + rekeningNo + "\n" +
                                                    "an." + lParam.CustomerName + "\n" +
                                                    "Tgl=" + lTime + "\n" +
                                                    "Nom=Rp." + valueDeli;

                        var dict = new Dictionary <string, string>();
                        dict.Add("user", UserSmsGateway);
                        dict.Add("password", PasswordSmsGateway);
                        dict.Add("senderid", SenderIDSmsGateway);
                        dict.Add("message", MessageSmsGateway);
                        dict.Add("msisdn", MsisdnSmsGateway);
                        string paramSMS = StringFacade.urlencodeString(dict);

                        string resultSMS = StringFacade.PostAPISMSGateway(urlAPI, paramSMS);
                        var    DesResult = JsonConvert.DeserializeObject <Model.mdlResultSmsGateway>(resultSMS);

                        if (DesResult.status == "SUCCESS")
                        {
                            mdlResult.ResultValue = "UPLOAD SUCCESS";

                            //ketika sms berhasil, update status isSMS
                            List <SqlParameter> sp_sms = new List <SqlParameter>()
                            {
                                new SqlParameter()
                                {
                                    ParameterName = "@DepositID", SqlDbType = SqlDbType.NVarChar, Value = lParam.DepositID
                                }
                            };

                            string query_sms    = "UPDATE DEPOSIT SET IsSMS = 1 WHERE DepositID =  @DepositID";
                            var    mdlResultSms = new Model.mdlResult();
                            Manager.DataFacade.DTSQLVoidCommand(query_sms, sp_sms);

                            //simpan juga log smsnya
                            LogFacade.InsertLogSMS_Service(urlAPI, paramSMS, resultSMS);
                        }
                        else
                        {
                            mdlResult.ResultValue = "UPLOAD SUCCESS but SMS FAILED";
                        }
                    }
                }
                else
                {
                    string ResultSubstring;

                    if (mdlResult.Result.Length > 500)
                    {
                        ResultSubstring = mdlResult.Result.Substring(0, 500);

                        mdlResult.Result = ResultSubstring;
                    }
                }

                mdlResultList.Add(mdlResult);
            }

            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }
Ejemplo n.º 19
0
        public static Model.mdlResultList InsertBBMRatio(List <Model.mdlBBMRatioParam> lParamlist)
        {
            var mdlResultList = new List <Model.mdlResult>();

            foreach (var lParam in lParamlist)
            {
                var mdlResult = new Model.mdlResult();

                bool lCheckRatioBBM = CheckbyRatioID(lParam.RatioID);
                if (lCheckRatioBBM == false)
                {
                    mdlResult.Result = "|| RatioID : " + lParam.RatioID + " " + "|| IDExist ||";
                    mdlResultList.Add(mdlResult);
                }
                else
                {
                    List <SqlParameter> sp = new List <SqlParameter>()
                    {
                        new SqlParameter()
                        {
                            ParameterName = "@RatioID", SqlDbType = SqlDbType.NVarChar, Value = lParam.RatioID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@BranchID", SqlDbType = SqlDbType.NVarChar, Value = lParam.BranchID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@EmployeeID", SqlDbType = SqlDbType.NVarChar, Value = lParam.EmployeeID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@VehicleID", SqlDbType = SqlDbType.NVarChar, Value = lParam.VehicleID
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Km", SqlDbType = SqlDbType.NVarChar, Value = lParam.Km
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Liter", SqlDbType = SqlDbType.NVarChar, Value = lParam.Liter
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Harga", SqlDbType = SqlDbType.NVarChar, Value = lParam.Harga
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Latitude", SqlDbType = SqlDbType.NVarChar, Value = lParam.Latitude
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Longitude", SqlDbType = SqlDbType.NVarChar, Value = lParam.Longitude
                        },
                        new SqlParameter()
                        {
                            ParameterName = "@Date", SqlDbType = SqlDbType.NVarChar, Value = lParam.Date
                        }
                    };

                    string query = @"INSERT INTO RatioBBM (RatioID, BranchID, EmployeeID, VehicleID, Km,Liter, Harga, Latitude, Longitude, Date) " +
                                   "VALUES (@RatioID, @BranchID, @EmployeeID, @VehicleID, @Km,@Liter, @Harga, @Latitude, @Longitude, @Date) ";

                    mdlResult.Result = Manager.DataFacade.DTSQLVoidCommand(query, sp);

                    if (mdlResult.Result == "1")
                    {
                    }
                    else
                    {
                        string ResultSubstring;

                        if (mdlResult.Result.Length > 500)
                        {
                            ResultSubstring = mdlResult.Result.Substring(0, 500);

                            mdlResult.Result = ResultSubstring;
                        }
                    }

                    mdlResultList.Add(mdlResult);
                }
            }

            var mdlResultListnew = new Model.mdlResultList();

            mdlResultListnew.ResultList = mdlResultList;
            return(mdlResultListnew);
        }