private void Trip_Delete(object sender, ASPxGridViewCustomDataCallbackEventArgs e, string tripId)
    {
        C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
        elog.Platform_isWeb();
        elog.Controller = HttpContext.Current.User.Identity.Name;
        elog.ActionLevel_isTRIP(SafeValue.SafeInt(tripId, 0));
        elog.Remark = "Trip delete";
        elog.log();
        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmJobDet2), "Id='" + tripId + "'");
        C2.CtmJobDet2 trip = C2.ManagerEdi.ORManager.GetObject(query) as C2.CtmJobDet2;
        C2.ManagerEdi.ORManager.ExecuteDelete(typeof(C2.CtmJobDet2), "Id='" + tripId + "'");
        //C2.Manager.ORManager.StartTracking(trip, Wilson.ORMapper.InitialState.Updated);
        //C2.Manager.ORManager.PersistChanges(trip);

        //EGL_JobTrip_AfterEndTrip("", SafeValue.SafeString(trip.Det1Id, "0"));

        string sql = string.Format(@"delete from job_cost where TripNo='{0}'", tripId);

        C2.ManagerEdi.ORManager.ExecuteScalar(sql);


        string re = HttpContext.Current.User.Identity.Name + "," + trip.Id + "," + trip.DriverCode;

        e.Result = re;
    }
示例#2
0
    private string Trip_New(string jobType, int tripId)
    {
        string no = SafeValue.SafeString(Request.QueryString["no"]);

        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmJobDet2), "Id='" + tripId + "'");
        C2.CtmJobDet2 trip = C2.Manager.ORManager.GetObject(query) as C2.CtmJobDet2;

        string sql = string.Format(@"select max(TripIndex) from CTM_JobDet2 where JobType=@JobType and JobNo=@JobNo");
        List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();

        list.Add(new ConnectSql_mb.cmdParameters("@JobNo", no, SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@JobType", jobType, SqlDbType.NVarChar, 100));
        string maxIdex  = SafeValue.SafeString(ConnectSql_mb.ExecuteScalar(sql, list).context, "//00");
        int    n        = SafeValue.SafeInt(maxIdex.Substring(maxIdex.LastIndexOf("/") + 1), 0) + 1;
        string str      = (100 + n).ToString().Substring(1);
        string fromCode = trip.ToCode;
        string toCode   = trip.FromCode;

        trip.BookingDate = DateTime.Today;
        trip.TripIndex   = no + "/" + jobType + "/" + str;
        trip.Self_Ind    = "No";
        trip.JobNo       = no;
        //trip.FromDate = DateTime.Today;
        //trip.ToDate = DateTime.Today;
        trip.CreateUser = HttpContext.Current.User.Identity.Name;
        trip.CreateTime = DateTime.Now;
        trip.UpdateUser = HttpContext.Current.User.Identity.Name;
        trip.UpdateTime = DateTime.Now;
        trip.JobType    = jobType;
        trip.TripCode   = jobType;
        trip.ReturnType = "Y";
        trip.ToCode     = toCode;
        trip.FromCode   = fromCode;
        trip.Statuscode = "P";
        C2.Manager.ORManager.StartTracking(trip, Wilson.ORMapper.InitialState.Inserted);
        C2.Manager.ORManager.PersistChanges(trip);

        string userId = HttpContext.Current.User.Identity.Name;

        C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
        elog.Platform_isWeb();
        elog.Controller = userId;
        elog.ActionLevel_isJOB(trip.Id);
        elog.setActionLevel(trip.Id, CtmJobEventLogRemark.Level.Trip, 1, "");

        return(trip.Id + "_" + trip.TripIndex);
    }
    private void Trip_Update(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        ASPxGridView grd       = sender as ASPxGridView;
        ASPxLabel    lb_tripId = grd.FindEditFormTemplateControl("lb_tripId") as ASPxLabel;
        string       tripId    = SafeValue.SafeString(lb_tripId.Text, "");

        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmJobDet2), "Id='" + tripId + "'");;
        C2.CtmJobDet2 trip       = C2.ManagerEdi.ORManager.GetObject(query) as C2.CtmJobDet2;
        string        Driver_old = "";

        bool isNew = false;

        if (trip == null)
        {
            isNew = true;
            trip  = new C2.CtmJobDet2();
        }
        else
        {
            Driver_old = trip.DriverCode;
        }

        ASPxDropDownEdit dde_Trip_ContNo = grd.FindEditFormTemplateControl("dde_Trip_ContNo") as ASPxDropDownEdit;
        ASPxTextBox      dde_Trip_ContId = grd.FindEditFormTemplateControl("dde_Trip_ContId") as ASPxTextBox;
        //ASPxButtonEdit btn_CfsCode = grd.FindEditFormTemplateControl("btn_CfsCode") as ASPxButtonEdit;
        //ASPxComboBox cbb_Trip_BayCode = grd.FindEditFormTemplateControl("cbb_Trip_BayCode") as ASPxComboBox;
        //ASPxComboBox cbb_Carpark = grd.FindEditFormTemplateControl("cbb_Carpark") as ASPxComboBox;
        ASPxComboBox cbb_Trip_TripCode = grd.FindEditFormTemplateControl("cbb_Trip_TripCode") as ASPxComboBox;

        ASPxButtonEdit btn_DriverCode  = grd.FindEditFormTemplateControl("btn_DriverCode") as ASPxButtonEdit;
        ASPxButtonEdit btn_TowheadCode = grd.FindEditFormTemplateControl("btn_TowheadCode") as ASPxButtonEdit;
        ASPxButtonEdit btn_ChessisCode = grd.FindEditFormTemplateControl("btn_ChessisCode") as ASPxButtonEdit;
        //ASPxComboBox cbb_Trip_SubletFlag = grd.FindEditFormTemplateControl("cbb_Trip_SubletFlag") as ASPxComboBox;
        //ASPxTextBox txt_SubletHauliername = grd.FindEditFormTemplateControl("txt_SubletHauliername") as ASPxTextBox;
        //ASPxComboBox cbb_StageCode = grd.FindEditFormTemplateControl("cbb_StageCode") as ASPxComboBox;
        //ASPxComboBox cbb_StageStatus = grd.FindEditFormTemplateControl("cbb_StageStatus") as ASPxComboBox;
        ASPxComboBox cbb_Trip_StatusCode = grd.FindEditFormTemplateControl("cbb_Trip_StatusCode") as ASPxComboBox;
        ASPxComboBox cmb_DoubleMounting  = grd.FindEditFormTemplateControl("cmb_DoubleMounting") as ASPxComboBox;
        ASPxDateEdit txt_FromDate        = grd.FindEditFormTemplateControl("txt_FromDate") as ASPxDateEdit;
        ASPxTextBox  txt_Trip_fromTime   = grd.FindEditFormTemplateControl("txt_Trip_fromTime") as ASPxTextBox;
        ASPxDateEdit date_Trip_toDate    = grd.FindEditFormTemplateControl("date_Trip_toDate") as ASPxDateEdit;
        ASPxTextBox  txt_Trip_toTime     = grd.FindEditFormTemplateControl("txt_Trip_toTime") as ASPxTextBox;
        ASPxMemo     txt_Trip_Remark     = grd.FindEditFormTemplateControl("txt_Trip_Remark") as ASPxMemo;
        ASPxMemo     txt_Trip_FromCode   = grd.FindEditFormTemplateControl("txt_Trip_FromCode") as ASPxMemo;
        ASPxMemo     txt_Trip_ToCode     = grd.FindEditFormTemplateControl("txt_Trip_ToCode") as ASPxMemo;
        //ASPxSpinEdit spin_Price = grd.FindEditFormTemplateControl("spin_Price") as ASPxSpinEdit;
        ASPxComboBox cbb_zone = grd.FindEditFormTemplateControl("cbb_zone") as ASPxComboBox;
        //ASPxSpinEdit spin_Incentive1 = grd.FindEditFormTemplateControl("spin_Incentive1") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Incentive2 = grd.FindEditFormTemplateControl("spin_Incentive2") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Incentive3 = grd.FindEditFormTemplateControl("spin_Incentive3") as ASPxSpinEdit;
        //ASPxComboBox cbb_Incentive4 = grd.FindEditFormTemplateControl("cbb_Incentive4") as ASPxComboBox;

        //ASPxComboBox cbb_Overtime = grd.FindEditFormTemplateControl("cbb_Overtime") as ASPxComboBox;
        ASPxMemo txt_driver_remark = grd.FindEditFormTemplateControl("txt_driver_remark") as ASPxMemo;
        //ASPxComboBox cbb_OverDistance = grd.FindEditFormTemplateControl("cbb_OverDistance") as ASPxComboBox;

        ASPxTextBox fromPackingLot = grd.FindEditFormTemplateControl("txt_FromPL") as ASPxTextBox;
        ASPxTextBox toPackingLot   = grd.FindEditFormTemplateControl("txt_ToPL") as ASPxTextBox;
        //check_Trip_Status("0", trip.DriverCode,trip.Statuscode);

        //ASPxSpinEdit spin_Charge1 = grd.FindEditFormTemplateControl("spin_Charge1") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge2 = grd.FindEditFormTemplateControl("spin_Charge2") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge3 = grd.FindEditFormTemplateControl("spin_Charge3") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge4 = grd.FindEditFormTemplateControl("spin_Charge4") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge5 = grd.FindEditFormTemplateControl("spin_Charge5") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge6 = grd.FindEditFormTemplateControl("spin_Charge6") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge7 = grd.FindEditFormTemplateControl("spin_Charge7") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge8 = grd.FindEditFormTemplateControl("spin_Charge8") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge9 = grd.FindEditFormTemplateControl("spin_Charge9") as ASPxSpinEdit;
        //ASPxSpinEdit spin_Charge10 = grd.FindEditFormTemplateControl("spin_Charge10") as ASPxSpinEdit;
        ASPxSpinEdit   txt_trip_qty      = grd.FindEditFormTemplateControl("txt_trip_qty") as ASPxSpinEdit;
        ASPxButtonEdit txt_Trip_PkgsType = grd.FindEditFormTemplateControl("txt_Trip_PkgsType") as ASPxButtonEdit;
        ASPxSpinEdit   txt_trip_Wt       = grd.FindEditFormTemplateControl("txt_trip_Wt") as ASPxSpinEdit;
        ASPxSpinEdit   txt_trip_M3       = grd.FindEditFormTemplateControl("txt_trip_M3") as ASPxSpinEdit;

        if (dde_Trip_ContNo != null)
        {
            trip.ContainerNo = SafeValue.SafeString(dde_Trip_ContNo.Value);
        }
        if (dde_Trip_ContId != null)
        {
            trip.Det1Id = SafeValue.SafeInt(dde_Trip_ContId.Text, 0);
        }
        //trip.CfsCode = SafeValue.SafeString(btn_CfsCode.Value);
        //trip.BayCode = SafeValue.SafeString(cbb_Trip_BayCode.Value);
        if (btn_DriverCode != null)
        {
            trip.DriverCode = SafeValue.SafeString(btn_DriverCode.Value);
        }
        if (btn_TowheadCode != null)
        {
            trip.TowheadCode = SafeValue.SafeString(btn_TowheadCode.Value);
        }
        if (btn_ChessisCode != null)
        {
            trip.ChessisCode = SafeValue.SafeString(btn_ChessisCode.Value);
        }
        //trip.SubletFlag = SafeValue.SafeString(cbb_Trip_SubletFlag.Value);
        //trip.SubletHauliername = SafeValue.SafeString(txt_SubletHauliername.Text);
        if (cbb_Trip_TripCode != null)
        {
            trip.TripCode = SafeValue.SafeString(cbb_Trip_TripCode.Value);
        }
        if (cmb_DoubleMounting != null)
        {
            trip.DoubleMounting = SafeValue.SafeString(cmb_DoubleMounting.Value, "No");
        }
        //trip.StageCode = SafeValue.SafeString(cbb_StageCode.Value);
        //trip.Carpark = SafeValue.SafeString(cbb_Carpark.Value);
        //trip.StageStatus = SafeValue.SafeString(cbb_StageStatus.Value);
        if (cbb_Trip_StatusCode != null)
        {
            trip.Statuscode = SafeValue.SafeString(cbb_Trip_StatusCode.Value);
        }
        if (txt_FromDate != null)
        {
            trip.FromDate = SafeValue.SafeDate(txt_FromDate.Date, new DateTime(1990, 1, 1));
        }
        if (txt_Trip_fromTime != null)
        {
            trip.FromTime = SafeValue.SafeString(txt_Trip_fromTime.Text);
        }
        if (date_Trip_toDate != null)
        {
            trip.ToDate = SafeValue.SafeDate(date_Trip_toDate.Date, new DateTime(1990, 1, 1));
        }
        if (txt_Trip_toTime != null)
        {
            trip.ToTime = SafeValue.SafeString(txt_Trip_toTime.Text);
        }
        if (txt_Trip_Remark != null)
        {
            trip.Remark = SafeValue.SafeString(txt_Trip_Remark.Text);
        }
        if (txt_Trip_FromCode != null)
        {
            trip.FromCode = SafeValue.SafeString(txt_Trip_FromCode.Text);
        }
        if (txt_Trip_ToCode != null)
        {
            trip.ToCode = SafeValue.SafeString(txt_Trip_ToCode.Text);
        }
        //trip.Incentive1 = SafeValue.SafeDecimal(spin_Price.Text);
        if (cbb_zone != null)
        {
            trip.ParkingZone = SafeValue.SafeString(cbb_zone.Value);
        }
        //trip.Incentive1 = SafeValue.SafeDecimal(spin_Incentive1.Text);
        //trip.Incentive2 = SafeValue.SafeDecimal(spin_Incentive2.Text);
        //trip.Incentive3 = SafeValue.SafeDecimal(spin_Incentive3.Text);
        //trip.Incentive4 = SafeValue.SafeDecimal(cbb_Incentive4.Value);

        //trip.Overtime = SafeValue.SafeSqlString(cbb_Overtime.Value);
        //trip.OverDistance = SafeValue.SafeSqlString(cbb_OverDistance.Value);
        if (txt_driver_remark != null)
        {
            trip.Remark1 = SafeValue.SafeString(txt_driver_remark.Text);
        }
        if (fromPackingLot != null)
        {
            trip.FromParkingLot = SafeValue.SafeString(fromPackingLot.Text);
        }
        if (toPackingLot != null)
        {
            trip.ToParkingLot = SafeValue.SafeString(toPackingLot.Text);
        }

        //trip.Charge1 = SafeValue.SafeDecimal(spin_Charge1.Text);
        //trip.Charge2 = SafeValue.SafeDecimal(spin_Charge2.Text);
        //trip.Charge3 = SafeValue.SafeDecimal(spin_Charge3.Text);
        //trip.Charge4 = SafeValue.SafeDecimal(spin_Charge4.Text);
        //trip.Charge5 = SafeValue.SafeDecimal(spin_Charge5.Text);
        //trip.Charge6 = SafeValue.SafeDecimal(spin_Charge6.Text);
        //trip.Charge7 = SafeValue.SafeDecimal(spin_Charge7.Text);
        //trip.Charge8 = SafeValue.SafeDecimal(spin_Charge8.Text);
        //trip.Charge9 = SafeValue.SafeDecimal(spin_Charge9.Text);
        //trip.Charge10 = SafeValue.SafeDecimal(spin_Charge10.Text);


        if (txt_trip_qty != null)
        {
            trip.Qty = SafeValue.SafeInt(txt_trip_qty.Text, 0);
        }
        if (txt_Trip_PkgsType != null)
        {
            trip.PackageType = SafeValue.SafeString(txt_Trip_PkgsType.Text);
        }
        if (txt_trip_Wt != null)
        {
            trip.Weight = SafeValue.SafeDecimal(txt_trip_Wt.Text);
        }
        if (txt_trip_M3 != null)
        {
            trip.Volume = SafeValue.SafeDecimal(txt_trip_M3.Text);
        }


        if (isNew)
        {
            trip.JobNo = "0";
            C2.ManagerEdi.ORManager.StartTracking(trip, Wilson.ORMapper.InitialState.Inserted);
            C2.ManagerEdi.ORManager.PersistChanges(trip);
            Event_Log("", "TRIP", 1, SafeValue.SafeInt(trip.Id, 0), "");
        }
        else
        {
            C2.ManagerEdi.ORManager.StartTracking(trip, Wilson.ORMapper.InitialState.Updated);
            C2.ManagerEdi.ORManager.PersistChanges(trip);
            Event_Log("", "TRIP", 3, SafeValue.SafeInt(trip.Id, 0), "");

            //EGL_JobTrip_AfterEndTrip("", dde_Trip_ContId.Text);
        }
        string re = HttpContext.Current.User.Identity.Name + "," + trip.Id + "," + trip.DriverCode;

        if (!trip.DriverCode.Equals(Driver_old))
        {
            re += "," + Driver_old;
        }
        Session["NameTrip_" + trip.Id] = "Id=" + trip.Id + "";
        this.dsTrip.FilterExpression   = Session["NameTrip_" + trip.Id].ToString();
        if (this.grid_Trip.GetRow(0) != null)
        {
            this.grid_Trip.CancelEdit();
        }
        e.Result = re;
    }
示例#4
0
    private void set_signed_barcode_byid(XtraReport rpt, string orderNo, string id, string httpPath, string filename)
    {
        QR q = new QR();

        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmJobDet2), "Id=" + id + "");
        C2.CtmJobDet2 job = C2.Manager.ORManager.GetObject(query) as C2.CtmJobDet2;
        //string text = string.Format(@"JobNo:" + orderNo);

        Bitmap bt   = q.Create_QR(httpPath);
        string path = MapPath("~/files/barcode/");

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        string fileName = id + ".png";
        string filePath = path + fileName;

        if (File.Exists(filePath))
        {
            File.Delete(filePath);
        }
        bt.Save(Server.MapPath("~/files/barcode/") + fileName);

        DevExpress.XtraReports.UI.XRPictureBox qr_code = rpt.Report.FindControl("barcode", true) as DevExpress.XtraReports.UI.XRPictureBox;
        if (qr_code != null)
        {
            qr_code.ImageUrl = "/files/barcode/" + fileName;
        }

        string Signature_Consignee = "";
        string Signature_Driver    = "";
        string signature_time      = "";
        string signature_time1     = "";

        string sql_signature = string.Format(@"select Id,FileType,FileName,FilePath,FileNote,CreateDateTime From CTM_Attachment where FileType='Signature' and RefNo=@RefNo and charindex(@sType, FileNote,0)>0 and TripId=@tripId");
        List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();

        list.Add(new ConnectSql_mb.cmdParameters("@RefNo", orderNo, SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@sType", "Consignee", SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@tripId", id, SqlDbType.Int));
        DataTable dt = ConnectSql_mb.GetDataTable(sql_signature, list);

        if (dt.Rows.Count > 0)
        {
            if (job.EpodHardCopy == "HardCopy")
            {
                Signature_Consignee = dt.Rows[0]["FilePath"].ToString().Replace(@"/500", "");
            }
            else
            {
                Signature_Consignee = dt.Rows[0]["FilePath"].ToString();
            }
            signature_time = dt.Rows[0]["CreateDateTime"].ToString();
        }
        list = new List <ConnectSql_mb.cmdParameters>();
        list.Add(new ConnectSql_mb.cmdParameters("@RefNo", orderNo, SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@sType", "Driver", SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@tripId", id, SqlDbType.Int));
        dt = ConnectSql_mb.GetDataTable(sql_signature, list);
        if (dt.Rows.Count > 0)
        {
            Signature_Driver = dt.Rows[0]["FilePath"].ToString();
            signature_time1  = dt.Rows[0]["CreateDateTime"].ToString();
        }
        DevExpress.XtraReports.UI.XRPictureBox signature = rpt.Report.FindControl("signature", true) as DevExpress.XtraReports.UI.XRPictureBox;
        if (signature != null)
        {
            signature.ImageUrl = Signature_Consignee;
        }
        DevExpress.XtraReports.UI.XRLabel time = rpt.Report.FindControl("lbl_time", true) as DevExpress.XtraReports.UI.XRLabel;
        if (time != null)
        {
            time.Text = signature_time;
        }
        DevExpress.XtraReports.UI.XRPictureBox signature1 = rpt.Report.FindControl("signature1", true) as DevExpress.XtraReports.UI.XRPictureBox;
        if (signature1 != null)
        {
            signature1.ImageUrl = Signature_Driver;
        }
        DevExpress.XtraReports.UI.XRLabel time1 = rpt.Report.FindControl("lbl_time1", true) as DevExpress.XtraReports.UI.XRLabel;
        if (time1 != null)
        {
            time1.Text = signature_time1;
        }
    }
    protected void grid_wh_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string para = e.Parameters;

        if (Request.QueryString["no"] != null)
        {
            try
            {
                #region list
                if (list.Count > 0)
                {
                    string no      = SafeValue.SafeString(Request.QueryString["no"]);
                    string jobType = SafeValue.SafeString(Request.QueryString["type"]);
                    string client  = SafeValue.SafeString(Request.QueryString["clientId"]);

                    #region OK
                    if (para == "OK")
                    {
                        string jobNo   = "";
                        string refType = "";
                        bool   action  = false;
                        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmJob), "JobNo='" + no + "'");
                        C2.CtmJob     job  = C2.Manager.ORManager.GetObject(query) as C2.CtmJob;
                        C2.CtmJobDet2 trip = null;
                        if (job != null)
                        {
                            refType         = SafeValue.SafeString(Request.QueryString["action"]);
                            jobNo           = C2Setup.GetNextNo("", "CTM_Job_" + refType, DateTime.Today);
                            job.JobNo       = jobNo;
                            job.QuoteNo     = jobNo;
                            job.JobType     = refType;
                            job.JobDate     = DateTime.Now;
                            job.JobStatus   = "Confirmed";
                            job.QuoteStatus = "None";
                            C2.Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted);
                            C2.Manager.ORManager.PersistChanges(job);
                            C2Setup.SetNextNo("", "CTM_Job_" + refType, jobNo, DateTime.Today);


                            #region Trip
                            trip = new C2.CtmJobDet2();
                            string sql = string.Format(@"select max(TripIndex) from CTM_JobDet2 where JobType=@JobType and JobNo=@JobNo");
                            List <ConnectSql_mb.cmdParameters> list_cmd = new List <ConnectSql_mb.cmdParameters>();
                            list_cmd.Add(new ConnectSql_mb.cmdParameters("@JobNo", jobNo, SqlDbType.NVarChar, 100));
                            list_cmd.Add(new ConnectSql_mb.cmdParameters("@JobType", refType, SqlDbType.NVarChar, 100));
                            string maxIdex = SafeValue.SafeString(ConnectSql_mb.ExecuteScalar(sql, list_cmd).context, "//00");
                            int    n       = SafeValue.SafeInt(maxIdex.Substring(maxIdex.LastIndexOf("/") + 1), 0) + 1;
                            string str     = (100 + n).ToString().Substring(1);
                            trip.BookingDate = DateTime.Today;
                            trip.TripIndex   = jobNo + "/" + refType + "/" + str;
                            trip.JobNo       = jobNo;
                            trip.FromDate    = DateTime.Today;
                            trip.ToDate      = DateTime.Today;
                            trip.CreateUser  = HttpContext.Current.User.Identity.Name;
                            trip.CreateTime  = DateTime.Now;
                            trip.UpdateUser  = HttpContext.Current.User.Identity.Name;
                            trip.UpdateTime  = DateTime.Now;
                            trip.JobType     = refType;
                            trip.TripCode    = refType;
                            trip.Remark      = job.Remark;
                            trip.ToCode      = job.DeliveryTo;
                            trip.FromCode    = job.PickupFrom;
                            trip.Statuscode  = "P";
                            C2.Manager.ORManager.StartTracking(trip, Wilson.ORMapper.InitialState.Inserted);
                            C2.Manager.ORManager.PersistChanges(trip);


                            string            userId = HttpContext.Current.User.Identity.Name;
                            C2.CtmJobEventLog elog   = new C2.CtmJobEventLog();
                            elog.Platform_isWeb();
                            elog.Controller = userId;
                            elog.ActionLevel_isCONT(trip.Id);
                            elog.setActionLevel(trip.Id, CtmJobEventLogRemark.Level.Container, 1, "");
                            elog.log();
                            #endregion
                        }

                        for (int i = 0; i < list.Count; i++)
                        {
                            int     id      = list[i].id;
                            decimal qty     = list[i].qty;
                            decimal weight  = list[i].weight;
                            decimal volume  = list[i].volume;
                            decimal sku_qty = list[i].sku_qty;
                            decimal l       = list[i].l;
                            decimal h       = list[i].h;
                            decimal w       = list[i].w;
                            string  refNo   = list[i].refNo;
                            string  toLoc   = list[i].toLoc;
                            if (qty > 0)
                            {
                                Wilson.ORMapper.OPathQuery query1 = new Wilson.ORMapper.OPathQuery(typeof(C2.JobHouse), "Id=" + id + "");
                                C2.JobHouse house = C2.Manager.ORManager.GetObject(query1) as C2.JobHouse;
                                house.LineId        = id;
                                house.CargoType     = "OUT";
                                house.JobNo         = jobNo;
                                house.ContNo        = "";
                                house.JobType       = refType;
                                house.QtyOrig       = qty;
                                house.PackQty       = sku_qty;
                                house.Weight        = weight;
                                house.Volume        = volume;
                                house.WeightOrig    = weight;
                                house.VolumeOrig    = volume;
                                house.LandStatus    = "Normal";
                                house.DgClass       = "Normal";
                                house.DamagedStatus = "Normal";
                                house.LengthPack    = l;
                                house.WidthPack     = w;
                                house.HeightPack    = h;
                                house.RefNo         = no;
                                house.Qty           = qty;
                                house.OpsType       = "Delivery";
                                house.ClientId      = client;
                                house.CargoStatus   = "P";
                                house.TripId        = trip.Id;
                                house.TripIndex     = trip.TripIndex;
                                C2.Manager.ORManager.StartTracking(house, Wilson.ORMapper.InitialState.Inserted);
                                C2.Manager.ORManager.PersistChanges(house);
                                int lineId = house.Id;

                                if (refType == "TR")
                                {
                                    house.LineId      = lineId;
                                    house.Location    = toLoc;
                                    house.JobNo       = jobNo;
                                    house.TransferNo  = jobNo;
                                    house.RefNo       = refNo;
                                    house.CargoType   = "IN";
                                    house.RefNo       = no;
                                    house.CargoStatus = "P";
                                    C2.Manager.ORManager.StartTracking(house, Wilson.ORMapper.InitialState.Inserted);
                                    C2.Manager.ORManager.PersistChanges(house);
                                }
                                action = true;
                            }
                            else
                            {
                                action = false;
                            }
                        }
                        if (action)
                        {
                            e.Result = "Action Success! No is " + jobNo;
                        }
                        else
                        {
                            e.Result = "Action Error!";
                        }
                    }
                    #endregion

                    #region New WDO Trip
                    if (para == "NewTrip")
                    {
                        bool action = false;
                        for (int i = 0; i < list.Count; i++)
                        {
                            int     id      = list[i].id;
                            decimal qty     = list[i].qty;
                            decimal weight  = list[i].weight;
                            decimal volume  = list[i].volume;
                            decimal sku_qty = list[i].sku_qty;
                            decimal l       = list[i].l;
                            decimal h       = list[i].h;
                            decimal w       = list[i].w;
                            string  refNo   = list[i].refNo;
                            string  toLoc   = list[i].toLoc;
                            if (qty > 0)
                            {
                                Wilson.ORMapper.OPathQuery query1 = new Wilson.ORMapper.OPathQuery(typeof(C2.JobHouse), "Id=" + id + "");
                                C2.JobHouse house = C2.Manager.ORManager.GetObject(query1) as C2.JobHouse;
                                house.LineId        = id;
                                house.CargoType     = "OUT";
                                house.JobNo         = no;
                                house.ContNo        = "";
                                house.JobType       = jobType;
                                house.QtyOrig       = qty;
                                house.PackQty       = sku_qty;
                                house.Weight        = weight;
                                house.Volume        = volume;
                                house.WeightOrig    = weight;
                                house.VolumeOrig    = volume;
                                house.LandStatus    = "Normal";
                                house.DgClass       = "Normal";
                                house.DamagedStatus = "Normal";
                                house.LengthPack    = l;
                                house.WidthPack     = w;
                                house.HeightPack    = h;
                                house.RefNo         = no;
                                house.Qty           = qty;
                                house.OpsType       = "Delivery";
                                house.ClientId      = client;
                                house.TripIndex     = SafeValue.SafeString(cbb_TripNo.Text);
                                house.TripId        = SafeValue.SafeInt(cbb_TripNo.Value, 0);
                                house.CargoStatus   = "P";
                                C2.Manager.ORManager.StartTracking(house, Wilson.ORMapper.InitialState.Inserted);
                                C2.Manager.ORManager.PersistChanges(house);
                            }
                            action = true;
                        }
                        if (action)
                        {
                            e.Result = "Success";
                        }
                        else
                        {
                            e.Result = "Action Error!";
                        }
                    }
                    #endregion
                }
                else
                {
                    e.Result = "Pls Select at least one Cargo";
                }
                #endregion
            }
            catch { }
        }
    }