コード例 #1
0
        public int UpdateAll_tjms5(Tobk request)
        {
            int Result = -1;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection("TMS"))
                {
                    //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 (request.TrxNo.Length > 0)
                    {
                        int    TrxNo                    = Modfunction.ReturnZero(request.TrxNo.ToString());
                        string EquipmentType            = Modfunction.SQLSafeValue(Modfunction.CheckNull(request.EquipmentType));
                        string EquipmentTypeDescription = Modfunction.SQLSafeValue(Modfunction.CheckNull(request.EquipmentTypeDescription));
                        string ContainerNo              = Modfunction.SQLSafeValue(Modfunction.CheckNull(request.ContainerNo));
                        string CargoDescription         = Modfunction.SQLSafeValue(Modfunction.CheckNull(request.CargoDescription));
                        double Volume                   = Modfunction.ReturnDobule(request.Volume);
                        double ChargeWeight             = Modfunction.ReturnDobule(request.ChargeWeight);
                        double ChgWtRoundUp             = Modfunction.ReturnDobule(request.ChgWtRoundUp);
                        string VehicleNo                = Modfunction.SQLSafeValue(Modfunction.CheckNull(request.VehicleNo));
                        int    LineItemNo               = Modfunction.ReturnZero(request.LineItemNo.ToString());

                        //int TrxNo = Modfunction.ReturnZero(request.TrxNo.ToString());
                        //string EquipmentType = Modfunction.SQLSafeValue(request.EquipmentType);
                        //string EquipmentTypeDescription = Modfunction.SQLSafeValue(request.EquipmentTypeDescription);
                        //string ContainerNo = Modfunction.SQLSafeValue(request.ContainerNo);
                        //string CargoDescription = Modfunction.SQLSafeValue(request.CargoDescription);
                        //int Volume = Modfunction.ReturnZero(request.Volume.ToString());
                        //int ChargeWeight = Modfunction.ReturnZero(request.ChargeWeight.ToString());
                        //int ChgWtRoundUp = Modfunction.ReturnZero(Modfunction.CheckNull(request.ChgWtRoundUp));
                        //string VehicleNo = Modfunction.SQLSafeValue(request.VehicleNo);
                        //int LineItemNo = Modfunction.ReturnZero(request.LineItemNo.ToString());


                        string strSql = "";
                        if (LineItemNo != 0)
                        {
                            strSql = "Update tjms5 set " +
                                     "EquipmentType=" + EquipmentType + " , " +
                                     "EquipmentTypeDescription=" + EquipmentTypeDescription + " ," +
                                     "ContainerNo=" + ContainerNo + " , " +
                                     "CargoDescription=" + CargoDescription + " , " +
                                     "Volume=" + Volume + " ," +
                                     "ChargeWeight=" + ChargeWeight + " , " +
                                     "ChgWtRoundUp=" + ChgWtRoundUp + ",  " +
                                     "EditFlag=(select EditFlag from tovt1 where VehicleTypeDescription=" + EquipmentTypeDescription + " )," +
                                     " VehicleNo=" + VehicleNo + " " +
                                     "Where LineItemNo =" + LineItemNo + " And TrxNo=" + TrxNo + "";
                            db.ExecuteSql(strSql);

                            strSql = "  update tjms2 set ChargeWeight = (select sum(ChgWtRoundUp) from tjms5 where TrxNo=" + TrxNo + ")  Where LineItemNo =1 and TrxNo=" + TrxNo + " ";
                            db.ExecuteSql(strSql);
                        }
                    }
                    //    }
                    //}
                    Result = 1;

                    //}
                }
            }
            catch { throw; }
            return(Result);
        }
コード例 #2
0
        public int insert_tjms5(Tobk request)
        {
            int Result = -1;

            try
            {
                using (var db = DbConnectionFactory.OpenDbConnection("TMS"))
                {
                    //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 (request.TrxNo.Length > 0)
                    {
                        int    TrxNo                    = Modfunction.ReturnZero(request.TrxNo.ToString());
                        string EquipmentType            = Modfunction.SQLSafeValue(Modfunction.CheckNull(request.EquipmentType));
                        string EquipmentTypeDescription = Modfunction.SQLSafeValue(Modfunction.CheckNull(request.EquipmentTypeDescription));
                        string ContainerNo              = Modfunction.SQLSafeValue(Modfunction.CheckNull(request.ContainerNo));
                        string CargoDescription         = Modfunction.SQLSafeValue(Modfunction.CheckNull(request.CargoDescription));
                        double Volume                   = Modfunction.ReturnDobule(request.Volume);
                        double ChargeWeight             = Modfunction.ReturnDobule(request.ChargeWeight);
                        double ChgWtRoundUp             = Modfunction.ReturnDobule(request.ChgWtRoundUp);
                        string VehicleNo                = Modfunction.SQLSafeValue(Modfunction.CheckNull(request.VehicleNo));
                        string startDateTime            = "(select  Top 1 ISNULL(StartDateTime,NULL) AS StartDateTime  from tjms4 where TrxNo=" + TrxNo + ")  ";
                        string endDateTime              = "(select  Top 1  ISNULL(EndDateTime,NULL) AS EndDateTime  from tjms4 where TrxNo=" + TrxNo + ")";
                        string strSql                   = "";



                        int          intMaxLineItemNo = 1;
                        List <Tjms5> list1            = db.Select <Tjms5>("Select Max(LineItemNo) LineItemNo from Tjms5 Where TrxNo = " + TrxNo);
                        if (list1 != null)
                        {
                            if (list1[0].LineItemNo > 0)
                            {
                                intMaxLineItemNo = list1[0].LineItemNo + 1;
                            }
                        }


                        if (intMaxLineItemNo != 0)
                        {
                            strSql = "insert into tjms5 (" +
                                     " TrxNo ," +
                                     " LineItemNo ," +
                                     " EquipmentType ," +
                                     " EquipmentTypeDescription  ," +
                                     " ContainerNo ," +
                                     " CargoDescription  ," +
                                     " Volume ," +
                                     " ChargeWeight ," +
                                     " ChgWtRoundUp ," +
                                     " editflag ," +
                                     " VehicleNo  " +

                                     "  )" +
                                     "values( " +
                                     TrxNo + " , " +
                                     intMaxLineItemNo + " , " +
                                     EquipmentType + " , " +
                                     EquipmentTypeDescription + " , " +
                                     ContainerNo + " , " +
                                     CargoDescription + " , " +
                                     Volume + " , " +
                                     ChargeWeight + " , " +
                                     ChgWtRoundUp + " , " +
                                     "(Select isnull(editFlag,'') From tovt1 where   VehicleTypeDescription =" + EquipmentTypeDescription + ")," +
                                     VehicleNo + "  " +

                                     ") ";
                            db.ExecuteSql(strSql);


                            strSql = "  update tjms2 set ChargeWeight = (select sum(ChgWtRoundUp) from tjms5 where TrxNo=" + TrxNo + ")  Where LineItemNo =1 and TrxNo=" + TrxNo + " ";
                            db.ExecuteSql(strSql);
                        }
                    }

                    //    }
                    //}
                    Result = 1;

                    //}
                }
            }
            catch { throw; }
            return(Result);
        }