private void Event_Log(string jobNo, string level, int c, int id, string status)
    {
        string userId = HttpContext.Current.User.Identity.Name;

        C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
        elog.Platform_isWeb();
        elog.Controller = userId;
        if (level == "JOB")
        {
            elog.ActionLevel_isJOB(id);
            elog.setActionLevel(id, CtmJobEventLogRemark.Level.Job, c, status);
        }
        if (level == "QUOTATION")
        {
            elog.ActionLevel_isJOB(id);
            elog.setActionLevel(id, CtmJobEventLogRemark.Level.Quotation, c, status);
        }
        if (level == "CONT")
        {
            elog.ActionLevel_isCONT(id);
            elog.setActionLevel(id, CtmJobEventLogRemark.Level.Container, c, status);
        }
        if (level == "TRIP")
        {
            elog.ActionLevel_isTRIP(id);
            elog.setActionLevel(id, CtmJobEventLogRemark.Level.Trip, c, status);
        }
        elog.log_edi();
    }
Beispiel #2
0
    protected void gv_tpt_trip_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string action = e.Parameters;

        if (action.Equals("Save"))
        {
            Trip_Update(sender, e, "");
            Job_Save(sender, e);
        }
        if (action.Equals("Complete"))
        {
            string tripId = SafeValue.SafeString(lbl_TripId.Text, "");

            Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmJobDet2), "Id='" + tripId + "'");
            C2.CtmJobDet2 trip = C2.Manager.ORManager.GetObject(query) as C2.CtmJobDet2;
            trip.Statuscode = "C";
            trip.FromDate   = trip.BookingDate;
            trip.FromTime   = trip.BookingTime;
            trip.ToDate     = trip.BookingDate;
            trip.ToTime     = trip.BookingTime;
            C2.Manager.ORManager.StartTracking(trip, Wilson.ORMapper.InitialState.Updated);
            C2.Manager.ORManager.PersistChanges(trip);

            C2.CtmJobDet2.tripStatusChanged(trip.Id);

            C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
            elog.Platform_isWeb();
            elog.Controller = HttpContext.Current.User.Identity.Name;
            elog.Remark     = "Update Trip";
            elog.ActionLevel_isTRIP(trip.Id);
            elog.log();
            e.Result = "Success";
        }
    }
    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;
    }
Beispiel #4
0
    public BizResult unVoidJob(string user)
    {
        BizResult res = new BizResult();

        if (this.job != null && this.job.Id > 0)
        {
            this.job.StatusCode = "USE";
            this.job.JobStatus  = "Confirmed";

            Manager.ORManager.StartTracking(this.job, Wilson.ORMapper.InitialState.Updated);
            Manager.ORManager.PersistChanges(this.job);
            C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
            elog.Platform_isWeb();
            elog.Controller = user;
            elog.ActionLevel_isJOB(this.job.Id);
            elog.setActionLevel(this.job.Id, CtmJobEventLogRemark.Level.Job, 8);
            elog.log();
            res.status = true;
        }
        else
        {
            res.context = "error: data empty";
        }
        return(res);
    }
 protected void grid_Transport_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
 {
     if (e.Parameters == "OK")
     {
         int    update_error_rowcount = 0;
         string user = HttpContext.Current.User.Identity.Name;
         for (int i = 0; i < list.Count; i++)
         {
             try
             {
                 Record r = list[i];
                 List <ConnectSql_mb.cmdParameters> par_list = new List <ConnectSql_mb.cmdParameters>();
                 par_list.Add(new ConnectSql_mb.cmdParameters("@Id", r.Id, SqlDbType.Int));
                 par_list.Add(new ConnectSql_mb.cmdParameters("@DriverCode", r.driver, SqlDbType.NVarChar, 100));
                 par_list.Add(new ConnectSql_mb.cmdParameters("@TptDate", r.TptDate, SqlDbType.NVarChar, 10));
                 par_list.Add(new ConnectSql_mb.cmdParameters("@TptTime", r.TptTime, SqlDbType.NVarChar, 10));
                 par_list.Add(new ConnectSql_mb.cmdParameters("@Statuscode", r.progress_new, SqlDbType.NVarChar, 10));
                 string sql_where = "";
                 if (r.progress_new == "P" || r.progress_new == "S")
                 {
                     sql_where = ",FromDate=@TptDate,FromTime=@TptTime";
                 }
                 if (r.progress_new == "C")
                 {
                     sql_where = ",ToDate=@TptDate,ToTime=@TptTime";
                 }
                 string sql = string.Format(@"update CTM_JobDet2 set DriverCode=@DriverCode,Statuscode=@Statuscode{0} where Id=@Id", sql_where);
                 // string.Format(@"update tpt_job set Driver='{1}',VehicleNo='{2}' where Id='{0}'", id, driver, progress);
                 //if (r.progress.Length == 0 && r.driver.Length > 0 && r.progress_new.Length == 0)
                 //{
                 //    sql = string.Format(@"update tpt_job set Driver='{1}',JobProgress='Confirmed',DeliveryIndex='{2}',TptTime='{3}',TptDate='{4}' where Id='{0}'", r.Id, r.driver, r.index, r.TptTime, r.TptDate);
                 //}
                 //else
                 //{
                 //    sql = string.Format(@"update tpt_job set Driver='{1}',DeliveryIndex='{2}',TptTime='{3}',JobProgress='{4}',TptDate='{5}' where Id='{0}'", r.Id, r.driver, r.index, r.TptTime, r.progress_new, r.TptDate);
                 //}
                 ConnectSql_mb.ExecuteNonQuery(sql, par_list);
                 C2.CtmJobDet2.tripStatusChanged(SafeValue.SafeInt(r.Id, 0));
                 C2.CtmJobEventLog lg = new C2.CtmJobEventLog();
                 lg.Platform_isWeb();
                 lg.Controller = user;
                 lg.setActionLevel(SafeValue.SafeInt(r.Id, 0), CtmJobEventLogRemark.Level.Trip, 4, ":" + r.progress_new);
                 lg.log();
             }
             catch
             {
                 update_error_rowcount++;
             }
         }
         if (update_error_rowcount > 0)
         {
             e.Result = update_error_rowcount + " Rows Save Error";
         }
         else
         {
             btn_Search_Click(null, null);
         }
     }
 }
    private void Job_New_Save(DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        DateTime date  = DateTime.Now;
        string   time4 = date.ToString("HHmm");

        string jobType   = SafeValue.SafeString(cbb_new_jobtype.Value, "IMP");
        string jobStatus = SafeValue.SafeString(cbb_new_jobstatus.Text, "Quoted");

        string jobType1 = jobType;

        string jobno       = "";
        string user        = HttpContext.Current.User.Identity.Name;
        string quoteNo     = "";
        string billingType = "None";

        if (jobType1 == "TPT")
        {
            billingType = "Job";
        }
        if (jobStatus == "Quoted")
        {
            quoteNo = C2Setup.GetNextNo("", "CTM_Job_" + jobStatus, date);
        }
        else
        {
            jobno   = C2Setup.GetNextNo("", "CTM_Job_" + jobType1, date);
            quoteNo = jobno;
        }
        string wh    = System.Configuration.ConfigurationManager.AppSettings["Warehosue"];
        string sql   = string.Format(@"insert into CTM_Job (JobNo,JobDate,EtaDate,EtdDate,CodDate,StatusCode,CreateBy,CreateDatetime,UpdateBy,UpdateDatetime,EtaTime,EtdTime,JobType,ClientId,YardRef,PickupFrom,DeliveryTo,Remark,WarehouseAddress,JobStatus,QuoteNo,QuoteStatus,QuoteDate,WareHouseCode,BillingType) values ('{0}','{4}',getdate(),getdate(),getdate(),'USE','{1}',getdate(),'{1}',getdate(),'{2}','{2}','{3}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','Pending',getdate(),'{13}','{14}') select @@identity", jobno, user, time4, cbb_new_jobtype.Value, txt_new_JobDate.Date, btn_new_ClientId.Text, "", txt_FromAddress.Text, txt_ToAddress.Text, txt_new_remark.Text, "", jobStatus, quoteNo, wh, billingType);
        int    jobId = SafeValue.SafeInt(ConnectSql_mb.ExecuteScalar(sql), 0);

        if (jobId > 0)
        {
            string            userId = HttpContext.Current.User.Identity.Name;
            C2.CtmJobEventLog elog   = new C2.CtmJobEventLog();
            elog.Platform_isWeb();
            elog.Controller = userId;
            if (jobStatus == "Quoted")
            {
                elog.setActionLevel(jobId, CtmJobEventLogRemark.Level.Quotation, 1);
                elog.ActionLevel_isQuoted(jobId);
                C2Setup.SetNextNo("", "CTM_Job_" + jobStatus, quoteNo, date);
                //GetJobRate(quoteNo, btn_new_ClientId.Text, SafeValue.SafeString(cbb_new_jobtype.Value));
                e.Result = quoteNo;
            }
            else
            {
                elog.setActionLevel(jobId, CtmJobEventLogRemark.Level.Job, 1);
                elog.ActionLevel_isJOB(jobId);
                C2Setup.SetNextNo("", "CTM_Job_" + jobType1, jobno, date);
                e.Result = jobno;
            }
            elog.log();
        }
    }
Beispiel #7
0
    private void Event_Log(string jobNo, string status, string note)
    {
        ASPxLabel Id     = this.grid_job.FindEditFormTemplateControl("lb_Id") as ASPxLabel;
        string    userId = HttpContext.Current.User.Identity.Name;
        int       jobId  = SafeValue.SafeInt(Id.Text, 0);

        C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
        elog.Platform_isWeb();
        elog.Controller = userId;
        elog.ActionLevel_isJOB(jobId);
        elog.Remark = note;
        elog.log();
    }
Beispiel #8
0
    private void update_ContStatus_trip(int contId, string type, string statucCode)
    {
        string JobNo       = SafeValue.SafeString(Request.QueryString["JobNo"]);
        string isWarehouse = SafeValue.SafeString(Request.QueryString["isWarehouse"]);
        string sql         = "";
        string status      = "";

        if (isWarehouse == "Yes")
        {
            if (type == "IMP")
            {
                status = "WHS-LD";
            }
            if (type == "EXP")
            {
                status = "WHS-MT";
            }
            if (type == "RET")
            {
                status = "Return";
            }
            sql = string.Format(@"update ctm_jobdet1 set StatusCode='{1}' where Id={0}", contId, status);
            ConnectSql_mb.ExecuteNonQuery(sql);
        }
        if (isWarehouse == "No")
        {
            if (type == "IMP")
            {
                status = "Customer-LD";
            }
            if (type == "EXP")
            {
                status = "Customer-MT";
            }
            if (type == "RET")
            {
                status = "Return";
            }
            sql = string.Format(@"update ctm_jobdet1 set StatusCode='{1}' where Id={0}", contId, status);
            ConnectSql_mb.ExecuteNonQuery(sql);
        }
        string userId = HttpContext.Current.User.Identity.Name;

        C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
        elog.Platform_isWeb();
        elog.Controller = userId;
        elog.ActionLevel_isCONT(contId);
        elog.setActionLevel(contId, CtmJobEventLogRemark.Level.Container, 4, status);
        elog.log();
    }
Beispiel #9
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 Job_New_Save(DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        DateTime date      = DateTime.Now;
        string   time4     = date.ToString("HHmm");
        string   jobType   = SafeValue.SafeString(cbb_new_jobtype.Value, "CRA");
        string   jobType1  = jobType;
        string   jobno     = "";
        string   jobStatus = SafeValue.SafeString(cbb_new_jobstatus.Text, "Quoted");
        string   user      = HttpContext.Current.User.Identity.Name;
        string   quoteNo   = "";

        if (jobStatus == "Quoted")
        {
            quoteNo = C2Setup.GetNextNo("", "CTM_Job_" + jobStatus, date);
        }
        else
        {
            jobno   = C2Setup.GetNextNo("", "CTM_Job_" + jobType1, date);
            quoteNo = jobno;
        }
        string wh  = System.Configuration.ConfigurationManager.AppSettings["Warehosue"];
        string sql = string.Format(@"insert into CTM_Job (JobNo,JobDate,EtaDate,EtdDate,CodDate,StatusCode,CreateBy,CreateDatetime,UpdateBy,UpdateDatetime,EtaTime,EtdTime,JobType,ClientId,YardRef,PickupFrom,DeliveryTo,Remark,WarehouseAddress,JobStatus,QuoteNo,QuoteStatus,QuoteDate,WareHouseCode,IsAdhoc) values ('{0}','{4}',getdate(),getdate(),getdate(),'USE','{1}',getdate(),'{1}',getdate(),'{2}','{2}','{3}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','Pending',getdate(),'{13}','Yes')", jobno, user, time4, cbb_new_jobtype.Value, txt_new_JobDate.Date, btn_new_ClientId.Text, "", "", txt_ToAddress.Text, txt_new_remark.Text, "", jobStatus, quoteNo, wh);
        int    i   = ConnectSql_mb.ExecuteNonQuery(sql);

        if (i == 1)
        {
            if (jobStatus == "Quoted")
            {
                C2Setup.SetNextNo("", "CTM_Job_" + jobStatus, quoteNo, date);
                //GetJobRate(quoteNo, btn_new_ClientId.Text, SafeValue.SafeString(cbb_new_jobtype.Value));
                e.Result = quoteNo;
            }
            else
            {
                C2Setup.SetNextNo("", "CTM_Job_" + jobType1, jobno, date);
                e.Result = jobno;
                C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
                elog.Platform_isWeb();
                elog.Controller = HttpContext.Current.User.Identity.Name;
                elog.fixActionInfo_ByJobNo(jobno);
                elog.Remark = "New Job";
                elog.log();
            }
        }
    }
Beispiel #11
0
    public void ContainerDetail_readyExport(string info)
    {
        JObject job      = (JObject)JsonConvert.DeserializeObject(HttpUtility.UrlDecode(Server.UrlDecode(info)));
        bool    status   = false;
        string  context  = "";
        string  user     = SafeValue.SafeString(job["user"]);
        int     contId   = SafeValue.SafeInt(job["contId"], 0);
        decimal wt       = SafeValue.SafeDecimal(job["wt"], 0);
        string  remark   = SafeValue.SafeString(job["remark"]);
        string  mobileNo = SafeValue.SafeString(job["mobileNo"]);

        if (contId > 0)
        {
            C2.CtmJobDet1Biz bz   = new C2.CtmJobDet1Biz(contId);
            C2.CtmJobDet1    det1 = bz.getData();

            if (det1 != null)
            {
                det1.Weight            = wt;
                det1.StatusCode        = "Customer-LD";
                det1.CfsStatus         = "Completed";
                det1.ScheduleStartDate = DateTime.Now;
                det1.ScheduleStartTime = DateTime.Now.ToString("HH:mm");
                det1.CompletionDate    = det1.ScheduleStartDate;
                det1.CompletionTime    = det1.ScheduleStartTime;
                det1.Remark2           = remark;
                C2.BizResult result = bz.update("skip");
                if (result.status)
                {
                    status = true;
                    C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
                    elog.Platform_isWeb();
                    elog.Controller = user;
                    elog.setActionLevel(det1.Id, CtmJobEventLogRemark.Level.Container, -1, "Container Ready Export [" + mobileNo + "]: " + (remark.Length > 0 ? " :" + remark : ""));
                    elog.log();
                }
            }
        }
        else
        {
            context = "Data Error";
        }
        Common.WriteJsonP(status, Common.StringToJson(context));
    }
Beispiel #12
0
    private string job_void()
    {
        ASPxLabel Id  = this.grid_job.FindEditFormTemplateControl("lb_Id") as ASPxLabel;
        string    sql = "update CTM_Job set StatusCode=case when StatusCode='CNL' then 'USE' else 'CNL' end where Id=" + Id.Text;

        if (ConnectSql.ExecuteSql(sql) > 0)
        {
            string            userId = HttpContext.Current.User.Identity.Name;
            int               jobId  = SafeValue.SafeInt(Id.Text, 0);
            C2.CtmJobEventLog elog   = new C2.CtmJobEventLog();
            elog.Platform_isWeb();
            elog.Controller = userId;
            elog.ActionLevel_isJOB(jobId);
            elog.Remark = "Job Void";
            elog.log();
            return("");
        }

        return("error");
    }
Beispiel #13
0
    private void Job_New_Save(DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        DateTime date      = DateTime.Now;
        string   time4     = date.ToString("HHmm");
        string   jobType   = SafeValue.SafeString(cbb_new_jobtype.Value, "CONSOL");
        string   jobStatus = SafeValue.SafeString(cbb_new_jobstatus.Text, "Quoted");
        //string jobType1 = "IMP";
        //if (jobType.IndexOf("EXP") > -1)
        //{
        //    jobType1 = "EXP";
        //}
        string jobType1 = jobType;

        string jobno   = "";
        string user    = HttpContext.Current.User.Identity.Name;
        string quoteNo = "";

        jobno = C2Setup.GetNextNo("I", "CI", date);

        string wh    = txt_new_WareHouseId.Text;// System.Configuration.ConfigurationManager.AppSettings["Warehosue"];
        string sql   = string.Format(@"insert into CTM_Job (JobNo,JobDate,EtaDate,EtdDate,CodDate,StatusCode,CreateBy,CreateDatetime,UpdateBy,UpdateDatetime,EtaTime,EtdTime,OrderType,ClientId,YardRef,PickupFrom,DeliveryTo,Remark,WarehouseAddress,JobStatus,QuoteNo,QuoteStatus,QuoteDate,WareHouseCode,IsTrucking,IsWarehouse,JobType) values ('{0}','{4}',getdate(),getdate(),getdate(),'USE','{1}',getdate(),'{1}',getdate(),'{2}','{2}','{3}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','Pending',getdate(),'{13}','Yes','No','I') select @@identity", jobno, user, time4, cbb_new_jobtype.Value, txt_new_JobDate.Date, btn_new_ClientId.Text, txt_DepotAddress.Text, txt_FromAddress.Text, txt_ToAddress.Text, txt_new_remark.Text, txt_WarehouseAddress.Text, jobStatus, quoteNo, wh);
        int    jobId = SafeValue.SafeInt(ConnectSql_mb.ExecuteScalar(sql), 0);

        if (jobId > 0)
        {
            string            userId = HttpContext.Current.User.Identity.Name;
            C2.CtmJobEventLog elog   = new C2.CtmJobEventLog();
            elog.Platform_isWeb();
            elog.Controller = userId;

            elog.setActionLevel(jobId, CtmJobEventLogRemark.Level.Job, 1);
            elog.ActionLevel_isJOB(jobId);
            C2Setup.SetNextNo("I", "CI", jobno, date);
            e.Result = jobno;
            elog.log();
        }
    }
Beispiel #14
0
    public BizResult jobBilling(string user)
    {
        BizResult res = new BizResult();

        if (this.job != null && this.job.Id > 0)
        {
            string sql = string.Format(@"select * from CTM_JobDet2 as det2
left outer join ctm_job as job on det2.JobNo=job.JobNo
where job.Id=@jobId and det2.Statuscode<>'C'");
            List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();
            list.Add(new ConnectSql_mb.cmdParameters("@jobId", this.job.Id, SqlDbType.Int));
            DataTable dt = ConnectSql_mb.GetDataTable(sql, list);
            if (dt.Rows.Count > 0)
            {
                res.context = "Have pending trips need to delivery";
            }
            else
            {
                sql = "update CTM_Job set StatusCode='CLS',JobStatus='Completed' where Id=@jobId";
                if (ConnectSql_mb.ExecuteNonQuery(sql, list).status)
                {
                    res.status = true;
                    C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
                    elog.Platform_isWeb();
                    elog.Controller = user;
                    elog.ActionLevel_isJOB(this.job.Id);
                    elog.setActionLevel(this.job.Id, CtmJobEventLogRemark.Level.Job, 7);
                    elog.log();
                }
            }
        }
        else
        {
            res.context = "error: data empty";
        }
        return(res);
    }
Beispiel #15
0
    public BizResult voidJob(string user)
    {
        BizResult res = new BizResult();

        if (this.job != null && this.job.Id > 0)
        {
            System.Collections.ObjectModel.Collection <C2.CtmJobDet1> det1 = C2.Manager.ORManager.GetCollection <C2.CtmJobDet1>("JobNo='" + this.job.JobNo + "'");
            C2.CtmJobDet1Biz det1Bz = new CtmJobDet1Biz(0);
            foreach (C2.CtmJobDet1 temp in det1)
            {
                det1Bz.setData(temp);
                det1Bz.delete(user);
            }


            this.job.StatusCode = "CNL";
            this.job.JobStatus  = "Voided";

            Manager.ORManager.StartTracking(this.job, Wilson.ORMapper.InitialState.Updated);
            Manager.ORManager.PersistChanges(this.job);

            C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
            elog.Platform_isWeb();
            elog.Controller = user;
            elog.ActionLevel_isJOB(this.job.Id);
            elog.setActionLevel(this.job.Id, CtmJobEventLogRemark.Level.Job, 5);
            elog.log();

            res.status = true;
        }
        else
        {
            res.context = "error: data empty";
        }
        return(res);
    }
    private void Job_New_Save(DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        DateTime date      = DateTime.Now;
        string   time4     = date.ToString("HHmm");
        string   jobType   = SafeValue.SafeString(cbb_new_jobtype.Value, "IMP");
        string   jobStatus = SafeValue.SafeString(cbb_new_jobstatus.Text, "Quoted");
        //string jobType1 = "IMP";
        //if (jobType.IndexOf("EXP") > -1)
        //{
        //    jobType1 = "EXP";
        //}
        string jobType1      = jobType;
        string isTrucking    = SafeValue.SafeString(cmb_IsTrucking.Value);
        string isWarehouse   = SafeValue.SafeString(cmb_IsWarehouse.Value);
        string subContract   = SafeValue.SafeString(cbb_Contractor.Value);
        string warehouseCode = SafeValue.SafeString(txt_new_WareHouseId.Text);
        string jobno         = "";
        string user          = HttpContext.Current.User.Identity.Name;
        string quoteNo       = "";
        string quoteStatus   = "Pending";

        if (jobStatus == "Quoted")
        {
            quoteNo = C2Setup.GetNextNo("", "CTM_Job_" + jobStatus, date);
        }
        else
        {
            quoteStatus = "None";
            jobno       = C2Setup.GetNextNo("", "CTM_Job_" + jobType1, date);
            quoteNo     = jobno;
        }

        string sql   = string.Format(@"insert into CTM_Job (JobNo,JobDate,EtaDate,EtdDate,CodDate,StatusCode,CreateBy,CreateDatetime,UpdateBy,UpdateDatetime,EtaTime,EtdTime,JobType,ClientId,YardRef,PickupFrom,DeliveryTo,Remark,WarehouseAddress,JobStatus,QuoteNo,QuoteStatus,QuoteDate,WareHouseCode,IsTrucking,IsWarehouse,Contractor) values ('{0}','{4}',getdate(),getdate(),getdate(),'USE','{1}',getdate(),'{1}',getdate(),'{2}','{2}','{3}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{14}',getdate(),'{13}','{15}','{16}','{17}') select @@identity", jobno, user, time4, cbb_new_jobtype.Value, txt_new_JobDate.Date, btn_new_ClientId.Text, txt_DepotAddress.Text, txt_FromAddress.Text, txt_ToAddress.Text, txt_new_remark.Text, txt_WarehouseAddress.Text, jobStatus, quoteNo, warehouseCode, quoteStatus, isTrucking, isWarehouse, subContract);
        int    jobId = SafeValue.SafeInt(ConnectSql_mb.ExecuteScalar(sql), 0);

        if (jobId > 0)
        {
            string            userId = HttpContext.Current.User.Identity.Name;
            C2.CtmJobEventLog elog   = new C2.CtmJobEventLog();
            elog.Platform_isWeb();
            elog.Controller = userId;
            if (jobStatus == "Quoted")
            {
                elog.setActionLevel(jobId, CtmJobEventLogRemark.Level.Quotation, 1);
                elog.ActionLevel_isQuoted(jobId);
                C2Setup.SetNextNo("", "CTM_Job_" + jobStatus, quoteNo, date);
                //GetJobRate(quoteNo, btn_new_ClientId.Text, SafeValue.SafeString(cbb_new_jobtype.Value));
                e.Result = quoteNo;
            }
            else
            {
                elog.setActionLevel(jobId, CtmJobEventLogRemark.Level.Job, 1);
                elog.ActionLevel_isJOB(jobId);
                C2Setup.SetNextNo("", "CTM_Job_" + jobType1, jobno, date);
                e.Result = jobno;
            }
            elog.log();

            sql = string.Format(@"update CTM_Job set JobNo={0} where Id={0}", jobId);
            ConnectSql.ExecuteSql(sql);
        }
    }
    private void Job_New_Save(DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        DateTime date      = DateTime.Now;
        string   time4     = date.ToString("HHmm");
        string   jobType   = SafeValue.SafeString(cbb_new_jobtype.Value, "IMP");
        string   jobStatus = SafeValue.SafeString(cbb_new_jobstatus.Text, "Quoted");
        //string jobType1 = "IMP";
        //if (jobType.IndexOf("EXP") > -1)
        //{
        //    jobType1 = "EXP";
        //}
        string jobType1    = jobType;
        string isTrucking  = SafeValue.SafeString(cmb_IsTrucking.Value);
        string isWarehouse = SafeValue.SafeString(cmb_IsWarehouse.Value);
        string subContract = SafeValue.SafeString(cbb_Contractor.Value);

        subContract = (subContract == "YES" ? "YES" : "NO");
        string warehouseCode = SafeValue.SafeString(txt_new_WareHouseId.Text);
        string jobno         = "";
        string user          = HttpContext.Current.User.Identity.Name;
        string quoteNo       = "";
        string quoteStatus   = "Pending";

        if (jobStatus == "Quoted")
        {
            quoteNo = C2Setup.GetNextNo("", "CTM_Job_" + jobStatus, date);
        }
        else
        {
            quoteStatus = "None";
            jobno       = C2Setup.GetNextNo("", "CTM_Job_" + jobType1, date);
            quoteNo     = jobno;
        }
        DateTime now = DateTime.Now;
        string   sql = string.Format(@"insert into CTM_Job (JobNo,JobDate,EtaDate,EtdDate,CodDate,StatusCode,CreateBy,CreateDatetime,UpdateBy,UpdateDatetime,EtaTime,EtdTime,JobType,ClientId,YardRef,PickupFrom,DeliveryTo,Remark,WarehouseAddress,JobStatus,QuoteNo,QuoteStatus,QuoteDate,WareHouseCode,IsTrucking,IsWarehouse,Contractor,DepotCode) values (@JobNo,@JobDate,@EtaDate,@EtdDate,@CodDate,@StatusCode,@CreateBy,@CreateDatetime,@UpdateBy,@UpdateDatetime,@EtaTime,@EtdTime,@JobType,@ClientId,@YardRef,@PickupFrom,@DeliveryTo,@Remark,@WarehouseAddress,@JobStatus,@QuoteNo,@QuoteStatus,@QuoteDate,@WareHouseCode,@IsTrucking,@IsWarehouse,@Contractor,@DepotCode) select @@identity");

        if (jobType1 == "WGR" || jobType1 == "WDO" || jobType1 == "TPT")
        {
            sql = string.Format(@"insert into CTM_Job (JobNo,JobDate,EtaDate,EtdDate,CodDate,StatusCode,CreateBy,CreateDatetime,UpdateBy,UpdateDatetime,EtaTime,EtdTime,JobType,ClientId,YardRef,PickupFrom,DeliveryTo,SpecialInstruction,WarehouseAddress,JobStatus,QuoteNo,QuoteStatus,QuoteDate,WareHouseCode,IsTrucking,IsWarehouse,Contractor,DepotCode) values (@JobNo,@JobDate,@EtaDate,@EtdDate,@CodDate,@StatusCode,@CreateBy,@CreateDatetime,@UpdateBy,@UpdateDatetime,@EtaTime,@EtdTime,@JobType,@ClientId,@YardRef,@PickupFrom,@DeliveryTo,@SpecialInstruction,@WarehouseAddress,@JobStatus,@QuoteNo,@QuoteStatus,@QuoteDate,@WareHouseCode,@IsTrucking,@IsWarehouse,@Contractor,@DepotCode) select @@identity");
        }
        List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();

        list.Add(new ConnectSql_mb.cmdParameters("@JobNo", jobno, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@JobDate", txt_new_JobDate.Date, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@EtaDate", now, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@EtdDate", now, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@CodDate", now, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@StatusCode", "USE", SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@CreateBy", user, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@CreateDatetime", now, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@UpdateBy", user, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@UpdateDatetime", now, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@EtaTime", time4, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@EtdTime", time4, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@JobType", cbb_new_jobtype.Value, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@ClientId", btn_new_ClientId.Text, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@YardRef", txt_DepotAddress.Text, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@PickupFrom", txt_FromAddress.Text, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@DeliveryTo", txt_ToAddress.Text, SqlDbType.NVarChar));
        if (jobType1 == "WGR" || jobType1 == "WDO" || jobType1 == "TPT")
        {
            list.Add(new ConnectSql_mb.cmdParameters("@SpecialInstruction", txt_new_remark.Text, SqlDbType.NVarChar));
        }
        else
        {
            list.Add(new ConnectSql_mb.cmdParameters("@Remark", txt_new_remark.Text, SqlDbType.NVarChar));
        }
        list.Add(new ConnectSql_mb.cmdParameters("@WarehouseAddress", txt_WarehouseAddress.Text, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@JobStatus", jobStatus, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@QuoteNo", quoteNo, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@QuoteStatus", quoteStatus, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@QuoteDate", now, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@WareHouseCode", warehouseCode, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@IsTrucking", isTrucking, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@IsWarehouse", isWarehouse, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@Contractor", cbb_Contractor.Value, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@DepotCode", btn_DepotCode.Text, SqlDbType.NVarChar));
        ConnectSql_mb.sqlResult res = ConnectSql_mb.ExecuteScalar(sql, list);
        if (res.status)
        {
            int               jobId  = SafeValue.SafeInt(res.context, 0);
            string            userId = HttpContext.Current.User.Identity.Name;
            C2.CtmJobEventLog elog   = new C2.CtmJobEventLog();
            elog.Platform_isWeb();
            elog.Controller = userId;
            if (jobStatus == "Quoted")
            {
                elog.setActionLevel(jobId, CtmJobEventLogRemark.Level.Quotation, 1);
                elog.ActionLevel_isQuoted(jobId);
                C2Setup.SetNextNo("", "CTM_Job_" + jobStatus, quoteNo, date);
                auto_add_trailer_trip(quoteNo, jobType1);
                //GetJobRate(quoteNo, btn_new_ClientId.Text, SafeValue.SafeString(cbb_new_jobtype.Value));
                e.Result = quoteNo;
            }
            else
            {
                elog.setActionLevel(jobId, CtmJobEventLogRemark.Level.Job, 1);
                elog.ActionLevel_isJOB(jobId);
                C2Setup.SetNextNo("", "CTM_Job_" + jobType1, jobno, date);
                auto_add_trailer_trip(jobno, jobType1);
                e.Result = jobno;
            }
            elog.log();
        }
    }
Beispiel #18
0
    private void Job_New_Save(DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        DateTime date      = DateTime.Now;
        string   time4     = date.ToString("HHmm");
        string   jobType   = SafeValue.SafeString(cbb_new_jobtype.Value, "IMP");
        string   jobStatus = SafeValue.SafeString(cbb_new_jobstatus.Text, "Quoted");
        //string jobType1 = "IMP";
        //if (jobType.IndexOf("EXP") > -1)
        //{
        //    jobType1 = "EXP";
        //}
        string jobType1   = jobType;
        string isTrucking = "No";

        if (cb_Trucking.Checked)
        {
            isTrucking = "Yes";
        }
        string isWarehouse = "No";

        if (cb_Warehouse.Checked)
        {
            isWarehouse = "Yes";
        }
        string isTransport = "No";

        if (cb_Transport.Checked)
        {
            isTransport = "Yes";
        }
        string isCrane = "No";

        if (cb_Crane.Checked)
        {
            isCrane = "Yes";
        }

        if (jobType == "IMP" || jobType == "EXP" || jobType == "LOC")
        {
            isTrucking = "Yes";
        }
        else if (jobType == "WGR" || jobType == "WDO" || jobType == "TPT")
        {
            isTransport = "Yes";
        }
        else if (jobType == "CRA")
        {
            isCrane = "Yes";
        }
        string warehouseCode = SafeValue.SafeString(txt_new_WareHouseId.Text);
        string jobno         = "";
        string user          = HttpContext.Current.User.Identity.Name;
        string quoteNo       = "";
        string quoteStatus   = "Pending";

        if (jobStatus == "Quoted")
        {
            quoteNo = C2Setup.GetNextNo("", "CTM_Job_" + jobStatus, txt_new_JobDate.Date);
        }
        else
        {
            quoteStatus = "None";
            jobno       = C2Setup.GetNextNo("", "CTM_Job_" + jobType1, txt_new_JobDate.Date);
            quoteNo     = jobno;
        }
        DateTime now = DateTime.Now;
        string   sql = string.Format(@"insert into CTM_Job (JobNo,JobDate,EtaDate,CodDate,StatusCode,CreateBy,CreateDatetime,UpdateBy,UpdateDatetime,EtaTime,EtdTime,JobType,JobStatus,QuoteNo,QuoteStatus,QuoteDate,WareHouseCode,IsTrucking,IsWarehouse,IsLocal,IsAdhoc) 
values (@JobNo,@JobDate,@EtaDate,@CodDate,@StatusCode,@CreateBy,@CreateDatetime,@UpdateBy,@UpdateDatetime,@EtaTime,@EtdTime,@JobType,@JobStatus,@QuoteNo,@QuoteStatus,@QuoteDate,@WareHouseCode,@IsTrucking,@IsWarehouse,@IsLocal,@IsAdhoc) select @@identity");
        List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();

        list.Add(new ConnectSql_mb.cmdParameters("@JobNo", jobno, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@JobDate", txt_new_JobDate.Date, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@EtaDate", now, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@CodDate", now, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@StatusCode", "USE", SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@CreateBy", user, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@CreateDatetime", now, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@UpdateBy", user, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@UpdateDatetime", now, SqlDbType.DateTime));
        list.Add(new ConnectSql_mb.cmdParameters("@EtaTime", time4, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@EtdTime", time4, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@JobType", cbb_new_jobtype.Value, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@JobStatus", jobStatus, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@QuoteNo", quoteNo, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@QuoteStatus", quoteStatus, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@QuoteDate", now, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@WareHouseCode", warehouseCode, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@IsTrucking", isTrucking, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@IsWarehouse", isWarehouse, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@IsLocal", isTransport, SqlDbType.NVarChar));
        list.Add(new ConnectSql_mb.cmdParameters("@IsAdhoc", isCrane, SqlDbType.NVarChar));

        ConnectSql_mb.sqlResult res = ConnectSql_mb.ExecuteScalar(sql, list);
        if (res.status)
        {
            int               jobId  = SafeValue.SafeInt(res.context, 0);
            string            userId = HttpContext.Current.User.Identity.Name;
            C2.CtmJobEventLog elog   = new C2.CtmJobEventLog();
            elog.Platform_isWeb();
            elog.Controller = userId;
            if (jobStatus == "Quoted")
            {
                elog.setActionLevel(jobId, CtmJobEventLogRemark.Level.Quotation, 1);
                elog.ActionLevel_isQuoted(jobId);
                C2Setup.SetNextNo("", "CTM_Job_" + jobStatus, quoteNo, date);
                //GetJobRate(quoteNo, btn_new_ClientId.Text, SafeValue.SafeString(cbb_new_jobtype.Value));
                e.Result = quoteNo;
            }
            else
            {
                elog.setActionLevel(jobId, CtmJobEventLogRemark.Level.Job, 1);
                elog.ActionLevel_isJOB(jobId);
                C2Setup.SetNextNo("", "CTM_Job_" + jobType1, jobno, date);
                e.Result = jobno;
            }
            elog.log();

            sql = string.Format(@"update CTM_Job set JobNo={0} where Id={0}", jobId);
            ConnectSql.ExecuteSql(sql);
        }
    }
    private void Trip_Update(object sender, ASPxGridViewCustomDataCallbackEventArgs e, string jobType)
    {
        try
        {
            string tripId = SafeValue.SafeString(lbl_TripId.Text, "");
            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        Driver_old = "";

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

            //ASPxDropDownEdit dde_Trip_ContNo = gv_tpt_trip.FindEditFormTemplateControl("dde_Trip_ContNo") as ASPxDropDownEdit;
            ASPxButtonEdit btn_ChessisCode = gv_tpt_trip.FindEditFormTemplateControl("btn_ChessisCode") as ASPxButtonEdit;
            ASPxComboBox   cbb_zone        = gv_tpt_trip.FindEditFormTemplateControl("cbb_zone") as ASPxComboBox;
            ASPxTextBox    dde_Trip_ContId = gv_tpt_trip.FindEditFormTemplateControl("dde_Trip_ContId") as ASPxTextBox;
            //ASPxButtonEdit btn_CfsCode = gv_tpt_trip.FindEditFormTemplateControl("btn_CfsCode") as ASPxButtonEdit;
            //ASPxComboBox cbb_Trip_BayCode = gv_tpt_trip.FindEditFormTemplateControl("cbb_Trip_BayCode") as ASPxComboBox;
            //ASPxComboBox cbb_Carpark = gv_tpt_trip.FindEditFormTemplateControl("cbb_Carpark") as ASPxComboBox;
            ASPxComboBox   cbb_Trip_TripCode = gv_tpt_trip.FindEditFormTemplateControl("cbb_Trip_TripCode") as ASPxComboBox;
            ASPxButtonEdit btn_ContNo        = gv_tpt_trip.FindEditFormTemplateControl("btn_ContNo") as ASPxButtonEdit;
            ASPxButtonEdit btn_DriverCode    = gv_tpt_trip.FindEditFormTemplateControl("btn_DriverCode") as ASPxButtonEdit;
            ASPxButtonEdit btn_Attended      = gv_tpt_trip.FindEditFormTemplateControl("btn_Attended") as ASPxButtonEdit;
            ASPxButtonEdit btn_TowheadCode   = gv_tpt_trip.FindEditFormTemplateControl("btn_TowheadCode") as ASPxButtonEdit;
            //ASPxComboBox cbb_Trip_SubletFlag = gv_tpt_trip.FindEditFormTemplateControl("cbb_Trip_SubletFlag") as ASPxComboBox;
            //ASPxTextBox txt_SubletHauliername = gv_tpt_trip.FindEditFormTemplateControl("txt_SubletHauliername") as ASPxTextBox;
            //ASPxComboBox cbb_StageCode = gv_tpt_trip.FindEditFormTemplateControl("cbb_StageCode") as ASPxComboBox;
            //ASPxComboBox cbb_StageStatus = gv_tpt_trip.FindEditFormTemplateControl("cbb_StageStatus") as ASPxComboBox;
            ASPxComboBox cbb_Trip_StatusCode = gv_tpt_trip.FindEditFormTemplateControl("cbb_Trip_StatusCode") as ASPxComboBox;
            ASPxComboBox cmb_DoubleMounting  = gv_tpt_trip.FindEditFormTemplateControl("cmb_DoubleMounting") as ASPxComboBox;
            ASPxDateEdit txt_FromDate        = gv_tpt_trip.FindEditFormTemplateControl("txt_FromDate") as ASPxDateEdit;
            ASPxTextBox  txt_Trip_fromTime   = gv_tpt_trip.FindEditFormTemplateControl("txt_Trip_fromTime") as ASPxTextBox;
            ASPxDateEdit date_Trip_toDate    = gv_tpt_trip.FindEditFormTemplateControl("date_Trip_toDate") as ASPxDateEdit;
            ASPxTextBox  txt_Trip_toTime     = gv_tpt_trip.FindEditFormTemplateControl("txt_Trip_toTime") as ASPxTextBox;
            ASPxMemo     txt_Trip_Remark     = gv_tpt_trip.FindEditFormTemplateControl("txt_Trip_Remark") as ASPxMemo;
            ASPxMemo     txt_Trip_FromCode   = gv_tpt_trip.FindEditFormTemplateControl("txt_Trip_FromCode") as ASPxMemo;
            ASPxMemo     txt_Trip_ToCode     = gv_tpt_trip.FindEditFormTemplateControl("txt_Trip_ToCode") as ASPxMemo;
            //ASPxSpinEdit spin_Incentive2 = gv_tpt_trip.FindEditFormTemplateControl("spin_Incentive2") as ASPxSpinEdit;

            ASPxMemo txt_driver_remark = gv_tpt_trip.FindEditFormTemplateControl("txt_driver_remark") as ASPxMemo;


            ASPxDateEdit date_BookingDate       = gv_tpt_trip.FindEditFormTemplateControl("date_BookingDate") as ASPxDateEdit;
            ASPxTextBox  txt_BookingTime        = gv_tpt_trip.FindEditFormTemplateControl("txt_BookingTime") as ASPxTextBox;
            ASPxTextBox  txt_BookingTime2       = gv_tpt_trip.FindEditFormTemplateControl("txt_BookingTime2") as ASPxTextBox;
            ASPxMemo     txt_BookingRemark      = gv_tpt_trip.FindEditFormTemplateControl("txt_BookingRemark") as ASPxMemo;
            ASPxMemo     txt_Trip_BillingRemark = gv_tpt_trip.FindEditFormTemplateControl("txt_Trip_BillingRemark") as ASPxMemo;
            ASPxMemo     txt_delivery_remark    = gv_tpt_trip.FindEditFormTemplateControl("txt_delivery_remark") as ASPxMemo;
            if (txt_delivery_remark != null)
            {
                trip.DeliveryRemark = txt_delivery_remark.Text;
            }
            ASPxMemo txt_billing_remark = gv_tpt_trip.FindEditFormTemplateControl("txt_billing_remark") as ASPxMemo;
            if (txt_billing_remark != null)
            {
                trip.BillingRemark = txt_billing_remark.Text;
            }
            ASPxMemo txt_Satifaction_Indator = gv_tpt_trip.FindEditFormTemplateControl("txt_Satifaction_Indator") as ASPxMemo;
            if (txt_Satifaction_Indator != null)
            {
                trip.Satisfaction = txt_Satifaction_Indator.Text;
            }
            ASPxComboBox cmb_Escort_Ind         = gv_tpt_trip.FindEditFormTemplateControl("cmb_Escort_Ind") as ASPxComboBox;
            ASPxMemo     txt_Trip_Escort_Remark = gv_tpt_trip.FindEditFormTemplateControl("txt_Trip_Escort_Remark") as ASPxMemo;
            if (cmb_Escort_Ind != null)
            {
                trip.Escort_Ind = SafeValue.SafeString(cmb_Escort_Ind.Value);
            }
            if (txt_Trip_Escort_Remark != null)
            {
                trip.Escort_Remark = SafeValue.SafeString(txt_Trip_Escort_Remark.Text);
            }
            ASPxSpinEdit txt_TotalHour      = gv_tpt_trip.FindEditFormTemplateControl("txt_TotalHour") as ASPxSpinEdit;
            ASPxSpinEdit txt_OtHour         = gv_tpt_trip.FindEditFormTemplateControl("txt_OtHour") as ASPxSpinEdit;
            ASPxTextBox  txt_ByUser         = gv_tpt_trip.FindEditFormTemplateControl("txt_ByUser") as ASPxTextBox;
            ASPxTextBox  txt_TrailerType    = gv_tpt_trip.FindEditFormTemplateControl("txt_TrailerType") as ASPxTextBox;
            ASPxTextBox  txt_VehicleType    = gv_tpt_trip.FindEditFormTemplateControl("txt_VehicleType") as ASPxTextBox;
            ASPxComboBox cbb_VehicleType    = gv_tpt_trip.FindEditFormTemplateControl("cbb_VehicleType") as ASPxComboBox;
            ASPxMemo     txt_DeliveryRemark = gv_tpt_trip.FindEditFormTemplateControl("txt_DeliveryRemark") as ASPxMemo;
            if (txt_TrailerType != null)
            {
                trip.RequestTrailerType = txt_TrailerType.Text;
            }
            if (txt_VehicleType != null)
            {
                trip.RequestVehicleType = txt_VehicleType.Text;
            }
            if (cbb_VehicleType != null)
            {
                trip.RequestVehicleType = cbb_VehicleType.Text;
            }
            if (txt_DeliveryRemark != null)
            {
                trip.DeliveryRemark = txt_DeliveryRemark.Text;
            }
            ASPxButtonEdit btn_AgentId   = gv_tpt_trip.FindEditFormTemplateControl("btn_AgentId") as ASPxButtonEdit;
            ASPxTextBox    txt_AgentName = gv_tpt_trip.FindEditFormTemplateControl("txt_AgentName") as ASPxTextBox;
            if (btn_AgentId != null)
            {
                trip.AgentId = btn_AgentId.Text;
            }
            if (txt_AgentName != null)
            {
                trip.AgentName = txt_AgentName.Text;
            }
            if (btn_ContNo != null)
            {
                trip.ContainerNo = SafeValue.SafeString(btn_ContNo.Text);
            }

            ASPxButtonEdit btn_Trailer = gv_tpt_trip.FindEditFormTemplateControl("btn_Trailer") as ASPxButtonEdit;
            if (btn_Trailer != null)
            {
                trip.ChessisCode = SafeValue.SafeString(btn_Trailer.Text);
            }
            //if (btn_ChessisCode != null)
            //    trip.ChessisCode = SafeValue.SafeString(btn_ChessisCode.Value);
            //if (cbb_zone != null)
            //    trip.ParkingZone = SafeValue.SafeString(cbb_zone.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)
            {
                if (btn_DriverCode.Text != "")
                {
                    trip.DriverCode = SafeValue.SafeString(btn_DriverCode.Text);
                }
                else
                {
                    trip.DriverCode = "";
                }
            }
            if (btn_Attended != null)
            {
                if (btn_Attended.Text != "")
                {
                    trip.DriverCode2 = SafeValue.SafeString(btn_Attended.Text);
                }
                else
                {
                    trip.DriverCode2 = "";
                }
            }
            if (btn_TowheadCode != null)
            {
                trip.TowheadCode = SafeValue.SafeString(btn_TowheadCode.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 (date_BookingDate != null)
            {
                trip.BookingDate = SafeValue.SafeDate(date_BookingDate.Date, new DateTime(1900, 1, 1));
            }
            if (txt_BookingTime != null)
            {
                trip.BookingTime = SafeValue.SafeString(txt_BookingTime.Text);
            }
            if (txt_BookingTime2 != null)
            {
                trip.BookingTime2 = SafeValue.SafeString(txt_BookingTime2.Text);
            }
            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.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);
            if (txt_BookingRemark != null)
            {
                trip.BookingRemark = txt_BookingRemark.Text;
            }
            if (txt_Trip_BillingRemark != null)
            {
                trip.BillingRemark = txt_Trip_BillingRemark.Text;
            }
            if (txt_OtHour != null)
            {
                trip.OtHour = SafeValue.SafeDecimal(txt_OtHour.Text);
            }
            if (txt_TotalHour != null)
            {
                trip.TotalHour = SafeValue.SafeDecimal(txt_TotalHour.Text);
            }
            if (txt_ByUser != null)
            {
                trip.ByUser = SafeValue.SafeString(txt_ByUser.Text);
            }

            ASPxDateEdit date_WarehouseScheduleDate = gv_tpt_trip.FindEditFormTemplateControl("date_WarehouseScheduleDate") as ASPxDateEdit;
            if (date_WarehouseScheduleDate != null)
            {
                trip.WarehouseScheduleDate = SafeValue.SafeDate(date_WarehouseScheduleDate.Date, new DateTime(1990, 1, 1));
            }
            ASPxDateEdit date_WarehouseStartDate = gv_tpt_trip.FindEditFormTemplateControl("date_WarehouseStartDate") as ASPxDateEdit;
            if (date_WarehouseStartDate != null)
            {
                trip.WarehouseStartDate = SafeValue.SafeDate(date_WarehouseStartDate.Date, new DateTime(1990, 1, 1));
            }
            ASPxDateEdit date_WarehouseEndDate = gv_tpt_trip.FindEditFormTemplateControl("date_WarehouseEndDate") as ASPxDateEdit;
            if (date_WarehouseEndDate != null)
            {
                trip.WarehouseEndDate = SafeValue.SafeDate(date_WarehouseEndDate.Date, new DateTime(1990, 1, 1));
            }
            ASPxMemo memo_WarehouseRemark = gv_tpt_trip.FindEditFormTemplateControl("memo_WarehouseRemark") as ASPxMemo;
            if (memo_WarehouseRemark != null)
            {
                trip.WarehouseRemark = memo_WarehouseRemark.Text;
            }
            ASPxComboBox cbb_WarehouseStatus = gv_tpt_trip.FindEditFormTemplateControl("cbb_WarehouseStatus") as ASPxComboBox;
            if (cbb_WarehouseStatus != null)
            {
                trip.WarehouseStatus = SafeValue.SafeString(cbb_WarehouseStatus.Value);
            }

            ASPxCheckBox ckb_epodCB1 = gv_tpt_trip.FindEditFormTemplateControl("ckb_epodCB1") as ASPxCheckBox;
            if (ckb_epodCB1 != null)
            {
                if (ckb_epodCB1.Checked)
                {
                    trip.EpodCB1 = "Yes";
                }
                else
                {
                    trip.EpodCB1 = "No";
                }
            }
            ASPxCheckBox ckb_epodCB2 = gv_tpt_trip.FindEditFormTemplateControl("ckb_epodCB2") as ASPxCheckBox;
            if (ckb_epodCB2 != null)
            {
                if (ckb_epodCB2.Checked)
                {
                    trip.EpodCB2 = "Yes";
                }
                else
                {
                    trip.EpodCB2 = "No";
                }
            }
            ASPxCheckBox ckb_epodCB3 = gv_tpt_trip.FindEditFormTemplateControl("ckb_epodCB3") as ASPxCheckBox;
            if (ckb_epodCB3 != null)
            {
                if (ckb_epodCB3.Checked)
                {
                    trip.EpodCB3 = "Yes";
                }
                else
                {
                    trip.EpodCB3 = "No";
                }
            }
            ASPxCheckBox ckb_epodCB4 = gv_tpt_trip.FindEditFormTemplateControl("ckb_epodCB4") as ASPxCheckBox;
            if (ckb_epodCB4 != null)
            {
                if (ckb_epodCB4.Checked)
                {
                    trip.EpodCB4 = "Yes";
                }
                else
                {
                    trip.EpodCB4 = "No";
                }
            }
            ASPxCheckBox ckb_epodCB5 = gv_tpt_trip.FindEditFormTemplateControl("ckb_epodCB5") as ASPxCheckBox;
            if (ckb_epodCB5 != null)
            {
                if (ckb_epodCB5.Checked)
                {
                    trip.EpodCB5 = "Yes";
                }
                else
                {
                    trip.EpodCB5 = "No";
                }
            }
            ASPxCheckBox ckb_epodCB6 = gv_tpt_trip.FindEditFormTemplateControl("ckb_epodCB6") as ASPxCheckBox;
            if (ckb_epodCB6 != null)
            {
                if (ckb_epodCB6.Checked)
                {
                    trip.EpodCB6 = "Yes";
                }
                else
                {
                    trip.EpodCB6 = "No";
                }
            }
            ASPxComboBox cbb_Self_Ind = gv_tpt_trip.FindEditFormTemplateControl("cbb_Self_Ind") as ASPxComboBox;
            if (cbb_Self_Ind != null)
            {
                trip.Self_Ind = SafeValue.SafeString(cbb_Self_Ind.Value, "No");
            }
            ASPxButtonEdit btn_SubCon_Code = gv_tpt_trip.FindEditFormTemplateControl("btn_SubCon_Code") as ASPxButtonEdit;
            if (btn_SubCon_Code != null)
            {
                trip.SubCon_Code = btn_SubCon_Code.Text;
            }
            ASPxComboBox cbb_SubCon_Code = gv_tpt_trip.FindEditFormTemplateControl("cbb_SubCon_Code") as ASPxComboBox;
            if (cbb_SubCon_Code != null)
            {
                trip.SubCon_Ind = SafeValue.SafeString(cbb_SubCon_Code.Value);
            }



            ASPxComboBox cbb_DirectInf = gv_tpt_trip.FindEditFormTemplateControl("cbb_DirectInf") as ASPxComboBox;
            if (cbb_DirectInf != null)
            {
                trip.DirectInf = cbb_DirectInf.Text;
            }



            //========= incentive
            ASPxSpinEdit spin_Charge_ERP        = gv_tpt_trip.FindEditFormTemplateControl("spin_Charge_ERP") as ASPxSpinEdit;
            ASPxSpinEdit spin_Charge_ParkingFee = gv_tpt_trip.FindEditFormTemplateControl("spin_Charge_ParkingFee") as ASPxSpinEdit;
            ASPxSpinEdit spin_Charge9           = gv_tpt_trip.FindEditFormTemplateControl("spin_Charge9") as ASPxSpinEdit;
            ASPxSpinEdit spin_Incentive1        = gv_tpt_trip.FindEditFormTemplateControl("spin_Incentive1") as ASPxSpinEdit;
            ASPxSpinEdit spin_Incentive2        = gv_tpt_trip.FindEditFormTemplateControl("spin_Incentive2") as ASPxSpinEdit;
            ASPxComboBox cbb_Incentive4         = gv_tpt_trip.FindEditFormTemplateControl("cbb_Incentive4") as ASPxComboBox;

            C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
            elog.Platform_isWeb();
            elog.Controller = HttpContext.Current.User.Identity.Name;

            trip.UpdateUser = HttpContext.Current.User.Identity.Name;
            trip.UpdateTime = DateTime.Now;
            C2.Manager.ORManager.StartTracking(trip, Wilson.ORMapper.InitialState.Updated);
            C2.Manager.ORManager.PersistChanges(trip);
            //EGL_JobTrip_AfterEndTrip("", dde_Trip_ContId.Text);
            elog.Remark = "Update Trip";

            elog.ActionLevel_isTRIP(trip.Id);
            elog.log();


            Dictionary <string, decimal> d = new Dictionary <string, decimal>();
            d.Add("Trip", SafeValue.SafeDecimal(spin_Incentive1.Text));
            d.Add("OverTime", SafeValue.SafeDecimal(spin_Incentive2.Text));
            d.Add("PSA", SafeValue.SafeDecimal(cbb_Incentive4.Text));

            C2.CtmJobDet2.Incentive_Save(trip.Id, d);

            d = new Dictionary <string, decimal>();
            d.Add("ERP", SafeValue.SafeDecimal(spin_Charge_ERP.Text));
            d.Add("ParkingFee", SafeValue.SafeDecimal(spin_Charge_ParkingFee.Text));
            d.Add("OTHER", SafeValue.SafeDecimal(spin_Charge9.Text));
            C2.CtmJobDet2.Claims_Save(trip.Id, d);

            Session["CTM_Trip_" + tripId] = "Id='" + tripId + "'";
            this.dsTrip.FilterExpression  = Session["CTM_Trip_" + tripId].ToString();
            if (this.gv_tpt_trip.GetRow(0) != null)
            {
                this.gv_tpt_trip.StartEdit(0);
            }
        }
        catch { }
        e.Result = "Success";
    }
Beispiel #20
0
    private string job_save()
    {
        string res = "";

        try
        {
            ASPxPageControl            pageControl = this.grid_job.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox                txt_JobNo   = this.grid_job.FindEditFormTemplateControl("txt_JobNo") as ASPxTextBox;
            string                     jobNo       = SafeValue.SafeString(txt_JobNo.Text, "");
            Wilson.ORMapper.OPathQuery query       = new Wilson.ORMapper.OPathQuery(typeof(C2.CtmJob), "JobNo='" + jobNo + "'");
            C2.CtmJob                  ctmJob      = C2.Manager.ORManager.GetObject(query) as C2.CtmJob;

            ASPxDateEdit jobDate = this.grid_job.FindEditFormTemplateControl("txt_JobDate") as ASPxDateEdit;
            bool         isNew   = false;
            if (ctmJob == null)
            {
                isNew        = true;
                ctmJob       = new C2.CtmJob();
                ctmJob.JobNo = C2Setup.GetNextNo("", "CTM_Job", jobDate.Date);
            }
            ASPxComboBox   cbb_JobType     = this.grid_job.FindEditFormTemplateControl("cbb_JobType") as ASPxComboBox;
            ASPxButtonEdit btn_ClientId    = this.grid_job.FindEditFormTemplateControl("btn_ClientId") as ASPxButtonEdit;
            ASPxTextBox    txt_ClientRefNo = this.grid_job.FindEditFormTemplateControl("txt_ClientRefNo") as ASPxTextBox;

            ASPxTextBox txt_notifiEmail = this.grid_job.FindEditFormTemplateControl("txt_notifiEmail") as ASPxTextBox;

            ASPxButtonEdit btn_SubClientId   = this.grid_job.FindEditFormTemplateControl("btn_SubClientId") as ASPxButtonEdit;
            ASPxButtonEdit txt_WareHouseId   = this.grid_job.FindEditFormTemplateControl("txt_WareHouseId") as ASPxButtonEdit;
            ASPxTextBox    txt_ClientContact = this.grid_job.FindEditFormTemplateControl("txt_ClientContact") as ASPxTextBox;

            ctmJob.ClientContact = SafeValue.SafeString(txt_ClientContact.Text);
            ctmJob.JobDate       = SafeValue.SafeDate(jobDate.Date, new DateTime(1753, 1, 1));
            ctmJob.JobType       = cbb_JobType.Text;
            ctmJob.ClientId      = btn_ClientId.Text;
            ctmJob.ClientRefNo   = txt_ClientRefNo.Text;
            ctmJob.EmailAddress  = txt_notifiEmail.Text;
            ctmJob.SubClientId   = btn_SubClientId.Text;

            if (txt_WareHouseId != null)
            {
                ctmJob.WareHouseCode = txt_WareHouseId.Text;
            }
            string userId = HttpContext.Current.User.Identity.Name;
            if (isNew)
            {
                ctmJob.StatusCode = "USE";

                ctmJob.CreateBy       = userId;
                ctmJob.CreateDateTime = DateTime.Now;
                ctmJob.UpdateBy       = userId;
                ctmJob.UpdateDateTime = DateTime.Now;
                C2.Manager.ORManager.StartTracking(ctmJob, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(ctmJob);
            }
            else
            {
                ctmJob.UpdateBy       = userId;
                ctmJob.UpdateDateTime = DateTime.Now;
                C2.Manager.ORManager.StartTracking(ctmJob, Wilson.ORMapper.InitialState.Updated);
                C2.Manager.ORManager.PersistChanges(ctmJob);

                C2.CtmJobEventLog elog = new C2.CtmJobEventLog();
                elog.Platform_isWeb();
                elog.Controller = userId;
                elog.ActionLevel_isJOB(ctmJob.Id);
                elog.Remark = "Job Update";
                elog.log();
            }

            if (isNew)
            {
                txt_JobNo.Text = ctmJob.JobNo;
                //txt_search_JobNo.Text = txt_JobNo.Text;
                C2Setup.SetNextNo("", "CTM_Job", ctmJob.JobNo, jobDate.Date);
            }

            //res = Job_Check_JobLevel(ctmJob.JobNo);

            Session["CTM_Job_" + txt_search_JobNo.Text] = "JobNo='" + ctmJob.JobNo + "'";
            this.dsJob.FilterExpression = Session["CTM_Job_" + txt_search_JobNo.Text].ToString();
            if (this.grid_job.GetRow(0) != null)
            {
                this.grid_job.StartEdit(0);
            }
        }
        catch { }

        return(res);
    }
    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 { }
        }
    }
Beispiel #22
0
    protected void grid_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string par = e.Parameters;

        string[] ar = par.Split('_');
        if (par == "OK")
        {
            #region Create Inv
            if (Request.QueryString["no"] != null)
            {
                try
                {
                    bool   action = false;
                    string res    = "";
                    string no     = SafeValue.SafeString(Request.QueryString["no"]);
                    string type   = SafeValue.SafeString(Request.QueryString["type"]);
                    if (type == "IMP" || type == "EXP")
                    {
                        string sql_c = string.Format(@"select count(*) from ctm_jobdet1 where JobNo='{0}' and StatusCode!='Completed'", no);
                        int    n     = SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql_c), 0);
                        n = 0;
                        if (n == 0)
                        {
                            action = true;
                        }
                        else
                        {
                            res = "Action Error!Not Completed Container,Can not Create Invoice";
                        }
                    }
                    else
                    {
                        action = true;
                    }
                    if (action)
                    {
                        #region Create Inv
                        string docId = "";
                        if (list.Count > 0)
                        {
                            string   billType = SafeValue.SafeString(cbb_BillType.Value);
                            string   jobNo    = SafeValue.SafeString(Request.QueryString["no"]);
                            string   client   = SafeValue.SafeString(Request.QueryString["client"]);
                            string   contType = SafeValue.SafeString(Request.QueryString["contType"]);
                            string   user     = HttpContext.Current.User.Identity.Name;
                            string   acCode   = EzshipHelper.GetAccArCode("", "SGD");
                            DateTime dtime    = txt_DocDt.Date;
                            string   invN     = C2Setup.GetNextNo("", "AR-IV", dtime);
                            string   termId   = EzshipHelper.GetTerm(client);
                            string   term     = EzshipHelper.GetTermCode(termId);
                            string   currency = cmb_CurrencyId.Text;
                            decimal  exrate   = SafeValue.SafeDecimal(spin_ExRate.Value);
                            string   sql_att  = string.Format(@"select ClientContact from ctm_job where JobNo='{0}'", jobNo);
                            string   contact  = SafeValue.SafeString(ConnectSql.ExecuteScalar(sql_att));

                            string[] currentPeriod = EzshipHelper.GetAccPeriod(dtime);
                            string   acYear        = currentPeriod[1];
                            string   acPeriod      = currentPeriod[0];

                            string sql = string.Format(@"insert into XAArInvoice (DocType,DocDate,PartyTo,DocNo,AcYear,AcPeriod,Term,DocDueDate,Description,
CurrencyId,MastType,ExRate,ExportInd,CancelDate,CancelInd,UserId,EntryDate,Eta,AcCode,AcSource,MastRefNo,Contact)
values('IV','{5:yyyy-MM-dd}','{4}','{0}','{6}','{7}','{8}','{5:yyyy-MM-dd}','',
'{9}','CTM',{10},'N','19000101','N','{1}',getdate(),'17530101','{2}','DB','{3}','{11}')
select @@IDENTITY", invN, user, acCode, jobNo, client, dtime, acYear, acPeriod, term, currency, exrate, contact);
                            docId = ConnectSql_mb.ExecuteScalar(sql);
                            C2Setup.SetNextNo("", "AR-IV", invN, dtime);
                            string code = "";
                            for (int i = 0; i < list.Count; i++)
                            {
                                int    id         = list[i].id;
                                string chgCode    = list[i].chgCode;
                                string chgcodeDes = list[i].chgCodedes;
                                if (IsCostCreated(id))
                                {
                                    C2.ComMethod.CreateInv(invN, id, docId, i, billType, currency, exrate);
                                }
                                else
                                {
                                    if (list.Count - i > 1)
                                    {
                                        code += chgcodeDes + " / ";
                                    }
                                    else
                                    {
                                        code += chgcodeDes;
                                    }
                                }
                            }
                            for (int i = 0; i < list1.Count; i++)
                            {
                                int    id      = list1[i].id;
                                string chgCode = list[i].chgCode;
                                if (IsCostCreated(id))
                                {
                                    C2.ComMethod.CreateWhInv(invN, id, docId);
                                }
                                else
                                {
                                    if (list.Count - i > 1)
                                    {
                                        code += chgCode + " / ";
                                    }
                                    else
                                    {
                                        code += chgCode;
                                    }
                                }
                            }
                            C2.XAArInvoice.update_invoice_mast(SafeValue.SafeInt(docId, 0));
                            if (code.Length == 0)
                            {
                                e.Result = invN;
                            }
                            else
                            {
                                e.Result = "Action Error!" + code + " already exist !";
                            }
                        }
                        else
                        {
                            e.Result = "Action Error!Please keyin select cost ";
                        }
                        #endregion

                        string            userId = HttpContext.Current.User.Identity.Name;
                        C2.CtmJobEventLog elog   = new C2.CtmJobEventLog();
                        elog.Platform_isWeb();
                        elog.Controller = userId;
                        elog.ActionLevel_isINVOICE(SafeValue.SafeInt(docId, 0));
                        elog.setActionLevel(SafeValue.SafeInt(docId, 0), CtmJobEventLogRemark.Level.Invoice, 3);
                        elog.log();
                    }
                    else
                    {
                        e.Result = res;
                    }
                }
                catch { }
            }
            #endregion
        }
        if (par == "Update")
        {
            #region Update Inv
            if (Request.QueryString["no"] != null)
            {
                try
                {
                    string no = SafeValue.SafeString(Request.QueryString["no"]);
                    if (list.Count > 0)
                    {
                        string  invN     = lbl_DocNo.Text;
                        string  sql      = string.Format(@"select SequenceId from  XAArInvoice where DocNo='{0}'", invN);
                        string  docId    = ConnectSql_mb.ExecuteScalar(sql);
                        string  currency = cmb_CurrencyId.Text;
                        decimal exrate   = SafeValue.SafeDecimal(spin_ExRate.Value);
                        string  code     = "";
                        for (int i = 0; i < list.Count; i++)
                        {
                            int    id         = list[i].id;
                            string chgCode    = list[i].chgCode;
                            string chgcodeDes = list[i].chgCodedes;
                            if (IsCostCreated(id))
                            {
                                C2.ComMethod.CreateInv(invN, id, docId, i, "", currency, exrate);
                            }
                            else
                            {
                                if (list.Count - i > 1)
                                {
                                    code += chgcodeDes + " / ";
                                }
                                else
                                {
                                    code += chgcodeDes;
                                }
                            }
                        }
                        if (code.Length == 0)
                        {
                            e.Result = invN;
                        }
                        else
                        {
                            e.Result = "Action Error!" + code + " already exist !";
                        }
                    }
                    else
                    {
                        e.Result = "Action Error!Please keyin select cost ";
                    }
                }
                catch (Exception ex) { throw new Exception(ex.Message + ex.StackTrace); }
            }
            #endregion
        }
        if (par == "Save")
        {
            #region Save All
            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    int     id        = list[i].id;
                    string  contNo    = list[i].contNo;
                    string  contType  = list[i].contType;
                    decimal price     = list[i].price;
                    decimal qty       = list[i].qty;
                    string  unit      = list[i].unit;
                    string  code      = list[i].chgCode;
                    string  des       = list[i].chgCodedes;
                    int     lineIndex = list[i].lineIndex;
                    string  remark    = list[i].remark;
                    string  groupBy   = list[i].groupBy;
                    decimal locAmt    = SafeValue.ChinaRound(qty * SafeValue.SafeDecimal(price, 0), 2);
                    string  sql       = string.Format(@"update job_cost set ContNo='{0}',ContType='{1}',Price={2},Qty={3},LocAmt={4},Unit='{6}',ChgCode='{7}',ChgCodeDes='{8}',LineIndex={9},Remark='{10}',GroupBy='{11}' where Id={5}",
                                                      contNo, contType, price, qty, locAmt, id, unit, code, des, lineIndex, remark, groupBy);
                    ConnectSql.ExecuteSql(sql);
                }
                e.Result = "Save Success";
            }
            else
            {
                e.Result = "Action Error!Please keyin select cost ";
            }
            #endregion
        }
        if (par == "Delete")
        {
            #region
            if (list.Count > 0)
            {
                bool   action = false;
                string no     = SafeValue.SafeString(Request.QueryString["no"]);
                for (int i = 0; i < list.Count; i++)
                {
                    int    id     = list[i].id;
                    string sql    = string.Format(@"select LineSource from job_cost where Id={0}", id);
                    string status = SafeValue.SafeString(ConnectSql_mb.ExecuteScalar(sql));
                    if (status != "S")
                    {
                        action = true;
                        sql    = string.Format(@"delete from job_cost where Id={0}", id);
                        ConnectSql.ExecuteSql(sql);
                    }
                    else
                    {
                        e.Result = "this can not delete ";
                    }
                }
                if (action)
                {
                    e.Result = "Action Success";
                }
            }
            else
            {
                e.Result = "Please keyin select cost ";
            }
            #endregion
        }
        if (ar.Length >= 2)
        {
            if (ar[0].Equals("ChargeUpdateline"))
            {
                Update_Inline(e);
            }
        }
    }