Exemplo n.º 1
0
    private string InsertPl(string mastType, string soNo, string doNo, string type)
    {
        string sql = string.Format(@"select mast.PartyId,p.termid as Term
,det.ProductCode as Sku,det.LotNo,det.Qty1 as Qty,det.Price,mast.Currency,mast.ExRate,det.Gst
,det.Des1
from wh_transDet det inner join wh_trans mast on mast.DoNO=det.DoNo and mast.DoType=det.DoType
left join xxparty p on p.partyid=mast.partyid 
where mast.DoNO='{0}' ", soNo);

        if (doNo.Length > 0)
        {
            sql = string.Format(@"select mast.PartyId,p.termid as Term
,det.ProductCode as Sku,det.LotNo,det.Qty1 as Qty,tsDet.Price,tsMast.Currency,tsMast.ExRate,tsDet.Gst
,det.Des1
from wh_DoDet det inner join wh_do mast on mast.DoNO=det.DoNo and mast.DoType=det.DoType
left join xxparty p on p.partyid=mast.partyid
left join wh_transdet tsDet on tsDet.ProductCode=det.ProductCode and tsDet.LotNo=det.LotNo
left join wh_trans tsMast on tsMast.doNO=tsDet.DoNo and tsMast.DoType=tsDet.DoType
where mast.DoNO='{1}'  and tsDet.DoNO='{0}' ", soNo, doNo);
        }
        string    invN  = "";
        int       invId = 0;
        DataTable tab   = ConnectSql.GetTab(sql);

        for (int i = 0; i < tab.Rows.Count; i++)
        {
            if (i == 0)
            {
                string partyId = SafeValue.SafeString(tab.Rows[0]["PartyId"]);
                string term    = SafeValue.SafeString(tab.Rows[0]["Term"]);
                #region invoice mast
                string counterType = "";
                if (type == "PL")
                {
                    counterType = "AP-PAYABLE";
                }
                else
                {
                    counterType = "AP-Voucher";
                }
                C2.XAApPayable inv = new C2.XAApPayable();

                inv.DocDate = DateTime.Today;
                invN        = C2Setup.GetNextNo("", counterType, inv.DocDate);
                inv.PartyTo = partyId;
                inv.DocType = type;
                inv.DocNo   = invN.ToString();
                string[] currentPeriod = EzshipHelper.GetAccPeriod(inv.DocDate);

                inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], inv.DocDate.Year);
                inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], inv.DocDate.Month);
                inv.Term     = term;

                //
                int dueDay = SafeValue.SafeInt(inv.Term.ToUpper().Replace("DAYS", "").Trim(), 0);
                inv.Description = "";
                inv.CurrencyId  = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                inv.ExRate      = 1;
                inv.AcCode      = EzshipHelper.GetAccArCode(inv.PartyTo, inv.CurrencyId);
                inv.AcSource    = "CR";

                inv.MastType  = mastType;
                inv.MastRefNo = soNo;
                inv.JobRefNo  = doNo;

                inv.ExportInd  = "N";
                inv.UserId     = HttpContext.Current.User.Identity.Name;
                inv.EntryDate  = DateTime.Now;
                inv.CancelDate = new DateTime(1900, 1, 1);
                inv.CancelInd  = "N";
                try
                {
                    C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Inserted);
                    C2.Manager.ORManager.PersistChanges(inv);
                    C2Setup.SetNextNo("", counterType, invN, inv.DocDate);
                    invId = inv.SequenceId;
                }
                catch
                {
                }
                #endregion
                if (invId < 1)
                {
                    return("");
                }
            }
            string  sku    = SafeValue.SafeString(tab.Rows[i]["Sku"]);
            string  des    = SafeValue.SafeString(tab.Rows[i]["Des1"]);
            string  lotNo  = SafeValue.SafeString(tab.Rows[i]["LotNo"]);
            int     qty    = SafeValue.SafeInt(tab.Rows[i]["Qty"], 0);
            decimal price  = SafeValue.SafeDecimal(tab.Rows[i]["Price"], 0);
            string  cur    = SafeValue.SafeString(tab.Rows[i]["Currency"]);
            decimal exRate = SafeValue.SafeDecimal(tab.Rows[i]["ExRate"], 0);
            decimal gst    = SafeValue.SafeDecimal(tab.Rows[i]["Gst"], 0);
            InsertPl_Det(invId, invN, type, i + 1, sku, lotNo, des, qty, price, cur, exRate, gst, soNo, doNo, mastType);
        }
        if (invId > 0)
        {
            UpdateMaster1(invId);
        }
        return(invN);
    }
Exemplo n.º 2
0
 protected void gv_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
 {
     e.NewValues["GroupName"]  = SafeValue.SafeString(e.NewValues["GroupName"]);
     e.NewValues["Note1"]      = SafeValue.SafeString(e.NewValues["Note1"]);
     e.NewValues["CreateDate"] = DateTime.Now;
 }
    private void SaveAndUpdate()
    {
        ASPxTextBox    cerId           = this.ASPxGridView1.FindEditFormTemplateControl("txt_Id") as ASPxTextBox;
        ASPxComboBox   cmb_PartyTo     = this.ASPxGridView1.FindEditFormTemplateControl("cmb_PartyTo") as ASPxComboBox;
        ASPxDateEdit   txt_CerDt       = this.ASPxGridView1.FindEditFormTemplateControl("txt_CerDt") as ASPxDateEdit;
        ASPxTextBox    txt_GstPermitNo = this.ASPxGridView1.FindEditFormTemplateControl("txt_GstPermitNo") as ASPxTextBox;
        ASPxSpinEdit   spin_GstPaidAmt = this.ASPxGridView1.FindEditFormTemplateControl("spin_GstPaidAmt") as ASPxSpinEdit;
        ASPxTextBox    serialNo        = this.ASPxGridView1.FindEditFormTemplateControl("txt_SerialNo") as ASPxTextBox;
        ASPxTextBox    mastRefNCtr     = this.ASPxGridView1.FindEditFormTemplateControl("txt_MastRefNo") as ASPxTextBox;
        ASPxTextBox    jobRefNCtr      = this.ASPxGridView1.FindEditFormTemplateControl("txt_JobRefNo") as ASPxTextBox;
        ASPxTextBox    jobType         = this.ASPxGridView1.FindEditFormTemplateControl("txt_MastType") as ASPxTextBox;
        ASPxButtonEdit btn_RefCurrency = this.ASPxGridView1.FindEditFormTemplateControl("btn_RefCurrency") as ASPxButtonEdit;
        ASPxSpinEdit   txt_RefExRate   = this.ASPxGridView1.FindEditFormTemplateControl("txt_RefExRate") as ASPxSpinEdit;

        C2.SeaCertificate cer = Manager.ORManager.GetObject(typeof(SeaCertificate), SafeValue.SafeInt(cerId.Text, 0)) as SeaCertificate;

        if (cer == null)// first insert invoice
        {
            cer              = new SeaCertificate();
            cer.GstPermitNo  = txt_GstPermitNo.Text;
            cer.GstPaidAmt   = SafeValue.SafeDecimal(spin_GstPaidAmt.Value);
            cer.HandingAgent = SafeValue.SafeString(cmb_PartyTo.Value);
            cer.CerDate      = txt_CerDt.Date;
            cer.RefNo        = mastRefNCtr.Text;
            cer.JobNo        = jobRefNCtr.Text;
            cer.RefType      = jobType.Text;
            cer.SerialNo     = serialNo.Text;
            cer.Currency     = btn_RefCurrency.Text;
            cer.ExRate       = SafeValue.SafeDecimal(txt_RefExRate.Value);
            try
            {
                C2.Manager.ORManager.StartTracking(cer, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(cer);
            }
            catch
            {
            }
        }
        else
        {
            cer.GstPermitNo  = txt_GstPermitNo.Text;
            cer.GstPaidAmt   = SafeValue.SafeDecimal(spin_GstPaidAmt.Value);
            cer.HandingAgent = SafeValue.SafeString(cmb_PartyTo.Value);
            cer.CerDate      = txt_CerDt.Date;
            cer.RefNo        = mastRefNCtr.Text;
            cer.JobNo        = jobRefNCtr.Text;
            cer.RefType      = jobType.Text;
            cer.SerialNo     = serialNo.Text;
            cer.Currency     = btn_RefCurrency.Text;
            cer.ExRate       = SafeValue.SafeDecimal(txt_RefExRate.Value);
            try
            {
                Manager.ORManager.StartTracking(cer, InitialState.Updated);
                Manager.ORManager.PersistChanges(cer);
            }
            catch
            {
            }
        }
        Session["ExportCertificate"]        = "Id=" + cer.Id;
        this.dsCertificate.FilterExpression = Session["ExportCertificate"].ToString();
        if (this.ASPxGridView1.GetRow(0) != null)
        {
            this.ASPxGridView1.StartEdit(0);
        }
    }
Exemplo n.º 4
0
    protected void grid_ref_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string          s           = e.Parameters;
        ASPxPageControl pageControl = this.grid_ref.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
        ASPxTextBox     masterId    = this.grid_ref.FindEditFormTemplateControl("txt_Id") as ASPxTextBox;
        string          userId      = HttpContext.Current.User.Identity.Name;
        ASPxLabel       closeIndStr = this.grid_ref.FindEditFormTemplateControl("lab_CloseInd") as ASPxLabel;
        ASPxTextBox     txt_RefN    = this.grid_ref.FindEditFormTemplateControl("txt_RefN") as ASPxTextBox;
        ASPxButton      btn         = this.grid_ref.FindControl("btn_CloseJob") as ASPxButton;
        string          sql         = string.Format("select StatusCode from air_ref  where Id={0}", SafeValue.SafeInt(masterId.Text, 0));
        string          statusCode  = SafeValue.SafeString(Manager.ORManager.ExecuteScalar(sql));

        if (s == "VoidMaster")
        {
            #region void master
            string sql_cnt = string.Format("select count(SequenceId) from XAArInvoiceDet where MastType='AE' and MastRefNo='{0}' ", txt_RefN.Text);
            int    cnt     = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql_cnt), 0);
            if (cnt > 0)
            {
                e.Result = "Billing";
                return;
            }
            if (statusCode == "CNL")
            {
                sql = string.Format("update air_ref set StatusCode='USE' where RefNo='{0}'", txt_RefN.Text);
                string sql1 = string.Format("update air_job set StatusCode='USE' where RefNo='{0}'", txt_RefN.Text);
                int    res  = Manager.ORManager.ExecuteCommand(sql);
                int    res1 = Manager.ORManager.ExecuteCommand(sql1);
                if (res > 0 && res1 > 0)
                {
                    EzshipLog.Log(txt_RefN.Text, "", "AE", "Unvoid");
                    e.Result = "Success";
                    //btn.Text = "Close Job";
                    //closeIndStr.Text = "C";
                }
                else
                {
                    e.Result = "Fail";
                }
            }
            else
            {
                string refType    = "AE";
                bool   closeByEst = EzshipHelper.GetCloseEstInd(txt_RefN.Text, refType);
                if (closeByEst)
                {
                    sql = string.Format("update air_ref set StatusCode='CNL' where RefNo='{0}'", txt_RefN.Text);
                    string sql1 = string.Format("update air_job set StatusCode='CNL' where RefNo='{0}'", txt_RefN.Text);
                    int    res  = Manager.ORManager.ExecuteCommand(sql);
                    int    res1 = Manager.ORManager.ExecuteCommand(sql1);
                    if (res > 0 && res1 > 0)
                    {
                        EzshipLog.Log(txt_RefN.Text, "", "AE", "Void");
                        e.Result = "Success";
                        //btn.Text = "Close Job";
                        //closeIndStr.Text = "C";
                    }
                    else
                    {
                        e.Result = "Fail";
                    }
                }
                else
                {
                    e.Result = "NoMatch";
                }
            }
            #endregion
        }
        if (s == "CloseJob")
        {
            #region close job

            if (statusCode == "CLS")
            {
                sql = string.Format("update air_ref set StatusCode='USE' where RefNo='{0}'", txt_RefN.Text);
                string sql1 = string.Format("update air_job set StatusCode='USE' where RefNo='{0}'", txt_RefN.Text);
                int    res  = Manager.ORManager.ExecuteCommand(sql);
                int    res1 = Manager.ORManager.ExecuteCommand(sql1);
                if (res > 0 && res1 > 0)
                {
                    EzshipLog.Log(txt_RefN.Text, "", "AE", "Open");
                    e.Result = "Success";
                    //btn.Text = "Close Job";
                    //closeIndStr.Text = "N";
                }
                else
                {
                    e.Result = "Fail";
                }
            }

            else
            {
                string refType    = "AE";
                bool   closeByEst = EzshipHelper.GetCloseEstInd(txt_RefN.Text, refType);
                if (closeByEst)
                {
                    sql = string.Format("update air_ref set StatusCode='CLS', CloseDate='{0}' ,CloseUser='******' where RefNo='{2}'", DateTime.Today.ToString("yyyy-MM-dd"), userId, txt_RefN.Text);
                    string sql1 = string.Format("update air_job set StatusCode='CLS' where RefNo='{0}'", txt_RefN.Text);

                    int res  = Manager.ORManager.ExecuteCommand(sql);
                    int res1 = Manager.ORManager.ExecuteCommand(sql1);
                    if (res > 0 && res1 > 0)
                    {
                        EzshipLog.Log(txt_RefN.Text, "", "AE", "Close");
                        e.Result = "Success";
                        //btn.Text = "Open Job";
                        //closeIndStr.Text = "Y";
                    }
                    else
                    {
                        e.Result = "Fail";
                    }
                }
                else
                {
                    e.Result = "NoMatch";
                }
            }
            #endregion
        }
    }
Exemplo n.º 5
0
 protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
 {
     //e.Values["Id"] = SafeValue.SafeString(e.Values["Id"]);
     string Id = SafeValue.SafeString(e.Values["Id"]);
 }
Exemplo n.º 6
0
    public void Attachment_AddMutiple(string info)
    {
        JObject job = (JObject)JsonConvert.DeserializeObject(HttpUtility.UrlDecode(Server.UrlDecode(info)));
        JArray  jar = (JArray)JsonConvert.DeserializeObject(job["list"].ToString());

        List <ConnectSql_mb.cmdParameters> list = null;

        ConnectSql_mb.cmdParameters cpar = null;
        string status  = "1";
        string context = Common.StringToJson("");

        //string sql = string.Format(@"insert into job_photo (JobNo,ContNo,Name,Path,UploadType,EntryDate,DoNo,OrderType,Remark,ShowCust) values (@OrderNo,@ContNo,@FileName,@FilePath,@FileType,Getdate(),@DoNo,@OrderType,@FileNote,@ShowCust)");
        string sql       = string.Format(@"insert into CTM_Attachment(RefNo,ContainerNo,FileName,FilePath,FileType,CreateDateTime,JobNo,JobType,FileNote,TripId) 
values (@OrderNo,@ContNo,@FileName,@FilePath,@FileType,Getdate(),@CargoId,@OrderType,@FileNote,@TripId)
select @@Identity");
        string fileStart = System.Configuration.ConfigurationManager.AppSettings["MobileServerUrl"].ToString();

        if (fileStart == null)
        {
            fileStart = "";
        }
        string CreateBy    = job["user"].ToString();
        string JobNo       = job["JobNo"].ToString();
        string ContainerNo = job["ContainerNo"].ToString();
        string TripId      = job["TripId"].ToString();
        string CargoId     = SafeValue.SafeString(job["CargoId"]);
        string JobType     = "CTM";
        string FileNote    = "";
        bool   ShowCust    = true;

        for (int i = 0; i < jar.Count; i++)
        {
            string fileEnd = jar[i]["FP"].ToString();
            fileEnd = fileEnd.Substring(0, fileEnd.LastIndexOf('/')) + "/500/" + fileEnd.Substring(fileEnd.LastIndexOf('/') + 1);
            fileEnd = fileStart + fileEnd;
            string FileType = jar[i]["FT"].ToString();
            string FileName = jar[i]["FN"].ToString();

            list = new List <ConnectSql_mb.cmdParameters>();
            cpar = new ConnectSql_mb.cmdParameters("@OrderNo", JobNo, SqlDbType.NVarChar, 100);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@ContNo", ContainerNo, SqlDbType.NVarChar, 100);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@CargoId", CargoId, SqlDbType.NVarChar, 100);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@TripId", TripId, SqlDbType.NVarChar, 100);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@FileType", FileType, SqlDbType.NVarChar, 100);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@OrderType", JobType, SqlDbType.NVarChar, 100);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@FileName", FileName, SqlDbType.NVarChar, 100);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@FilePath", fileEnd, SqlDbType.NVarChar, 100);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@CreateBy", CreateBy, SqlDbType.NVarChar, 100);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@FileNote", FileNote, SqlDbType.NVarChar, 300);
            list.Add(cpar);
            list.Add(new ConnectSql_mb.cmdParameters("@ShowCust", ShowCust, SqlDbType.Bit));
            ConnectSql_mb.sqlResult res = ConnectSql_mb.ExecuteScalar(sql, list);
            if (res.status)
            {
                //status = "1";
                //===========log
                C2.CtmJobEventLog lg = new C2.CtmJobEventLog();
                lg.Platform_isMobile();
                lg.Controller = CreateBy;
                lg.Lat        = SafeValue.SafeString(job["Lat"]);
                lg.Lng        = SafeValue.SafeString(job["Lng"]);
                //lg.fixActionInfo_ByAttachmentId(SafeValue.SafeInt(res.context, 0));
                //lg.Remark = "Attachment upload file:" + job["FileName"];
                lg.setActionLevel(SafeValue.SafeInt(res.context, 0), CtmJobEventLogRemark.Level.Attachment, 1, ":" + FileType + "[" + FileName + "]");
                lg.log();
            }
            else
            {
                status  = "0";
                context = (context == "" ? "Save error:" : ",") + FileName;
            }
        }

        context = Common.StringToJson(context);
        Common.WriteJsonP(status, context);
    }
Exemplo n.º 7
0
    public string GetImgUrl(string id, string jobNo)
    {
        string url = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(string.Format(@"select FilePath from Job_Attachment where JobNo='{0}' and RefNo='{1}'", id, jobNo))).Replace("\\", "/");

        return("/Photos/" + url);
    }
    protected void ASPxGridView1_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
    {
        ASPxTextBox invNCtr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;

        ASPxTextBox    title   = this.ASPxGridView1.FindEditFormTemplateControl("txt_Title") as ASPxTextBox;
        ASPxButtonEdit partyTo = this.ASPxGridView1.FindEditFormTemplateControl("txt_CustId") as ASPxButtonEdit;
        ASPxTextBox    docN    = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
        ASPxDateEdit   docDate = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocDt") as ASPxDateEdit;
        ASPxMemo       note    = this.ASPxGridView1.FindEditFormTemplateControl("txt_Note") as ASPxMemo;
        ASPxMemo       rmk     = this.ASPxGridView1.FindEditFormTemplateControl("txt_Remarks1") as ASPxMemo;
        // ASPxComboBox termId = this.ASPxGridView1.FindEditFormTemplateControl("txt_TermId") as ASPxComboBox;
        ASPxDateEdit   expireDt = this.ASPxGridView1.FindEditFormTemplateControl("txt_toDt") as ASPxDateEdit;
        ASPxButtonEdit docCurr  = this.ASPxGridView1.FindEditFormTemplateControl("txt_Currency") as ASPxButtonEdit;
        ASPxButtonEdit pol      = this.ASPxGridView1.FindEditFormTemplateControl("txt_Pol") as ASPxButtonEdit;
        ASPxButtonEdit pod      = this.ASPxGridView1.FindEditFormTemplateControl("txt_Pod") as ASPxButtonEdit;
        ASPxButtonEdit viaPort  = this.ASPxGridView1.FindEditFormTemplateControl("txt_ViaPort") as ASPxButtonEdit;


        ASPxTextBox  frequency = this.ASPxGridView1.FindEditFormTemplateControl("txt_Frequency") as ASPxTextBox;
        ASPxTextBox  attention = this.ASPxGridView1.FindEditFormTemplateControl("txt_Attention") as ASPxTextBox;
        ASPxTextBox  tsDay     = this.ASPxGridView1.FindEditFormTemplateControl("spin_TsDay") as ASPxTextBox;
        ASPxSpinEdit lclChg    = this.ASPxGridView1.FindEditFormTemplateControl("spin_Gp20") as ASPxSpinEdit;
        ASPxSpinEdit exRate    = this.ASPxGridView1.FindEditFormTemplateControl("spin_exRate") as ASPxSpinEdit;

        string invN = docN.Text;

        C2.SeaApQuote1 inv = Manager.ORManager.GetObject(typeof(SeaApQuote1), SafeValue.SafeInt(invNCtr.Text, 0)) as SeaApQuote1;
        if (inv == null)// first insert invoice
        {
            string counterType = "SeaLcl-ApQuotation";

            inv           = new SeaApQuote1();
            invN          = C2Setup.GetNextNo(counterType);
            inv.Title     = title.Text;
            inv.PartyTo   = SafeValue.SafeString(partyTo.Value, "");
            inv.QuoteNo   = invN.ToString();
            inv.QuoteDate = docDate.Date;
            inv.ImpExpInd = "E";
            inv.FclLclInd = "Lcl";
            // inv.Term = termId.Text;

            //inv.DocFromDate =SafeValue.SafeDate(fromDt.Text, DateTime.Now);
            inv.ExpireDate = SafeValue.SafeDate(expireDt.Text, DateTime.Now);
            inv.Rmk        = rmk.Text;
            inv.Note       = note.Text;
            inv.CurrencyId = docCurr.Text.ToString();
            inv.Frequency  = frequency.Text;
            inv.ExRate     = SafeValue.SafeDecimal(exRate.Value, 1);

            inv.Pol         = pol.Text;
            inv.Pod         = pod.Text;
            inv.ViaPort     = viaPort.Text;
            inv.Attention   = attention.Text;
            inv.TransmitDay = tsDay.Text;
            inv.LclChg      = SafeValue.SafeDecimal(lclChg.Value, 0);
            inv.Gp20        = 0;
            inv.Gp40        = 0;
            inv.Hc40        = 0;
            inv.CreateUser  = HttpContext.Current.User.Identity.Name;
            inv.CreateDate  = DateTime.Now;
            try
            {
                C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(inv);
                C2Setup.SetNextNo(counterType, inv.QuoteNo);
            }
            catch
            {
            }
        }
        else
        {
            inv.Title   = title.Text;
            inv.PartyTo = SafeValue.SafeString(partyTo.Value, "");

            inv.ExpireDate = SafeValue.SafeDate(expireDt.Text, DateTime.Now);
            inv.Rmk        = rmk.Text;
            inv.Note       = note.Text;
            inv.CurrencyId = docCurr.Text.ToString();
            inv.ExRate     = SafeValue.SafeDecimal(exRate.Value, 1);

            inv.Pol         = pol.Text;
            inv.Pod         = pod.Text;
            inv.ViaPort     = viaPort.Text;
            inv.Attention   = attention.Text;
            inv.TransmitDay = tsDay.Text;
            inv.LclChg      = SafeValue.SafeDecimal(lclChg.Value, 0);
            inv.Frequency   = frequency.Text;

            inv.UpdateUser = HttpContext.Current.User.Identity.Name;
            inv.UpdateDate = DateTime.Now;
            try
            {
                Manager.ORManager.StartTracking(inv, InitialState.Updated);
                Manager.ORManager.PersistChanges(inv);
            }
            catch
            {
            }
        }
        Session["SeaExpLclQuoteEdit"]       = "SequenceId=" + inv.SequenceId;
        this.dsApQuotation.FilterExpression = Session["SeaExpLclQuoteEdit"].ToString();
        if (this.ASPxGridView1.GetRow(0) != null)
        {
            this.ASPxGridView1.StartEdit(0);
        }
    }
Exemplo n.º 9
0
    private void job_save()
    {
        try
        {
            ASPxPageControl            pageControl = this.grid_job.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox                txt_JobNo   = pageControl.FindControl("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 = pageControl.FindControl("txt_JobDate") as ASPxDateEdit;
            bool         isNew   = false;
            if (ctmJob == null)
            {
                isNew        = true;
                ctmJob       = new C2.CtmJob();
                ctmJob.JobNo = C2Setup.GetNextNo("", "CTM_Job", jobDate.Date);
            }
            ASPxDateEdit jobEta = pageControl.FindControl("date_Eta") as ASPxDateEdit;
            ASPxDateEdit jobEtd = pageControl.FindControl("date_Etd") as ASPxDateEdit;
            //ASPxButtonEdit partyId = pageControl.FindControl("btn_PartyId") as ASPxButtonEdit;
            ASPxTextBox ves = pageControl.FindControl("txt_Ves") as ASPxTextBox;
            ASPxTextBox voy = pageControl.FindControl("txt_Voy") as ASPxTextBox;
            //ASPxButtonEdit carrier = pageControl.FindControl("btn_CarrierId") as ASPxButtonEdit;
            //ASPxTextBox CarrierBlNo = pageControl.FindControl("txt_CarrierBlNo") as ASPxTextBox;
            //ASPxTextBox CarrierBkgNo = pageControl.FindControl("txt_CarrierBkgNo") as ASPxTextBox;
            ASPxComboBox Terminal           = pageControl.FindControl("cbb_Terminal") as ASPxComboBox;
            ASPxMemo     PickupFrom         = pageControl.FindControl("txt_PickupFrom") as ASPxMemo;
            ASPxMemo     DeliveryTo         = pageControl.FindControl("txt_DeliveryTo") as ASPxMemo;
            ASPxMemo     Remark             = pageControl.FindControl("txt_Remark") as ASPxMemo;
            ASPxMemo     SpecialInstruction = pageControl.FindControl("txt_SpecialInstruction") as ASPxMemo;
            ASPxTextBox  txt_Pol            = pageControl.FindControl("txt_Pol") as ASPxTextBox;
            ASPxTextBox  txt_Pod            = pageControl.FindControl("txt_Pod") as ASPxTextBox;
            ASPxTextBox  txt_EtaTime        = pageControl.FindControl("txt_EtaTime") as ASPxTextBox;
            ASPxTextBox  txt_EtdTime        = pageControl.FindControl("txt_EtdTime") as ASPxTextBox;
            ASPxComboBox cbb_JobType        = pageControl.FindControl("cbb_JobType") as ASPxComboBox;
            //ASPxButtonEdit btn_ClientId = pageControl.FindControl("btn_ClientId") as ASPxButtonEdit;
            ASPxTextBox txt_ClientRefNo = pageControl.FindControl("txt_ClientRefNo") as ASPxTextBox;
            //ASPxButtonEdit btn_HaulierId = pageControl.FindControl("btn_HaulierId") as ASPxButtonEdit;
            ctmJob.JobDate = SafeValue.SafeDate(jobDate.Date, new DateTime(1753, 1, 1));
            ctmJob.EtaDate = SafeValue.SafeDate(jobEta.Date, new DateTime(1753, 1, 1));
            ctmJob.EtdDate = SafeValue.SafeDate(jobEtd.Date, new DateTime(1753, 1, 1));
            //ctmJob.PartyId = partyId.Text;
            ctmJob.Vessel             = ves.Text;
            ctmJob.Voyage             = voy.Text;
            ctmJob.CarrierId          = "";
            ctmJob.CarrierBlNo        = "";
            ctmJob.CarrierBkgNo       = "";
            ctmJob.Terminalcode       = SafeValue.SafeString(Terminal.Value);
            ctmJob.PickupFrom         = PickupFrom.Text;
            ctmJob.DeliveryTo         = DeliveryTo.Text;
            ctmJob.Remark             = Remark.Text;
            ctmJob.SpecialInstruction = SpecialInstruction.Text;
            ctmJob.Pol         = txt_Pol.Text;
            ctmJob.Pod         = txt_Pod.Text;
            ctmJob.EtaTime     = txt_EtaTime.Text;
            ctmJob.EtdTime     = txt_EtdTime.Text;
            ctmJob.JobType     = cbb_JobType.Text;
            ctmJob.ClientId    = "";
            ctmJob.ClientRefNo = txt_ClientRefNo.Text;
            ctmJob.HaulierId   = "";

            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);
            }

            if (isNew)
            {
                txt_JobNo.Text = ctmJob.JobNo;
                //txt_search_JobNo.Text = txt_JobNo.Text;
                C2Setup.SetNextNo("", "CTM_Job", ctmJob.JobNo, jobDate.Date);
            }
            Session["CTM_Job"]          = "JobNo='" + ctmJob.JobNo + "'";
            this.dsJob.FilterExpression = Session["CTM_Job"].ToString();
            if (this.grid_job.GetRow(0) != null)
            {
                this.grid_job.StartEdit(0);
            }
        }
        catch { }
    }
Exemplo n.º 10
0
        public static void jobCost_Create(string JobNo, string JobType, string ClientId, string BillClass)
        {
            List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();
            string sql = string.Format(@"select ChgCode,ChgCodeDes,Qty,Price,BillClass,BillScope,CurrencyId,ExRate 
from job_rate where ClientId=@ClientId and BillScope=@LineType and JobType=@JobType and BillClass=@BillClass and LineStatus=@LineStatus");

            list.Add(new ConnectSql_mb.cmdParameters("@ClientId", ClientId, SqlDbType.NVarChar, 100));
            list.Add(new ConnectSql_mb.cmdParameters("@LineType", "JOB", SqlDbType.NVarChar, 30));
            list.Add(new ConnectSql_mb.cmdParameters("@JobType", JobType, SqlDbType.NVarChar, 100));
            list.Add(new ConnectSql_mb.cmdParameters("@BillClass", BillClass, SqlDbType.NVarChar, 30));
            list.Add(new ConnectSql_mb.cmdParameters("@LineStatus", "N", SqlDbType.NVarChar, 30));
            DataTable dt = ConnectSql_mb.GetDataTable(sql, list);

            if (dt.Rows.Count == 0)
            {
                #region No JobType
                list = new List <ConnectSql_mb.cmdParameters>();
                sql  = string.Format(@"select ChgCode,ChgCodeDes,Qty,Price,BillClass,BillScope,CurrencyId,ExRate 
from job_rate where ClientId=@ClientId and BillScope=@LineType and BillClass=@BillClass and LineStatus=@LineStatus");
                list.Add(new ConnectSql_mb.cmdParameters("@ClientId", ClientId, SqlDbType.NVarChar, 100));
                list.Add(new ConnectSql_mb.cmdParameters("@LineType", "JOB", SqlDbType.NVarChar, 30));
                list.Add(new ConnectSql_mb.cmdParameters("@BillClass", BillClass, SqlDbType.NVarChar, 30));
                list.Add(new ConnectSql_mb.cmdParameters("@LineStatus", "N", SqlDbType.NVarChar, 30));
                dt = ConnectSql_mb.GetDataTable(sql, list);
                #endregion
                if (dt.Rows.Count == 0)
                {
                    #region Client=CASH
                    list = new List <ConnectSql_mb.cmdParameters>();
                    sql  = string.Format(@"select ChgCode,ChgCodeDes,Qty,Price,BillClass,BillScope,CurrencyId,ExRate 
from job_rate where ClientId=@ClientId and BillScope=@LineType and BillClass=@BillClass and LineStatus=@LineStatus");
                    list.Add(new ConnectSql_mb.cmdParameters("@ClientId", "CASH", SqlDbType.NVarChar, 100));
                    list.Add(new ConnectSql_mb.cmdParameters("@LineType", "JOB", SqlDbType.NVarChar, 30));
                    list.Add(new ConnectSql_mb.cmdParameters("@BillClass", BillClass, SqlDbType.NVarChar, 30));
                    list.Add(new ConnectSql_mb.cmdParameters("@LineStatus", "N", SqlDbType.NVarChar, 30));
                    dt = ConnectSql_mb.GetDataTable(sql, list);
                    #endregion
                }
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string  chgCode    = SafeValue.SafeString(dt.Rows[i]["ChgCode"]);
                string  chgCodeDes = SafeValue.SafeString(dt.Rows[i]["ChgCodeDes"]);
                decimal price      = SafeValue.SafeDecimal(dt.Rows[i]["Price"]);
                decimal qty        = SafeValue.SafeDecimal(dt.Rows[i]["Qty"]);
                string  scope      = SafeValue.SafeString(dt.Rows[i]["BillScope"]);
                string  billClass  = SafeValue.SafeString(dt.Rows[i]["BillClass"]);

                list = new List <ConnectSql_mb.cmdParameters>();
                sql  = string.Format(@"select Id from job_cost where LineType=@LineType and JobNo=@JobNo and BillClass=@BillClass and JobType=@JobType and LineSource=@LineSource and ChgCode=@ChgCode");
                list.Add(new ConnectSql_mb.cmdParameters("@LineType", "JOB", SqlDbType.NVarChar, 30));
                list.Add(new ConnectSql_mb.cmdParameters("@BillClass", BillClass, SqlDbType.NVarChar, 30));
                list.Add(new ConnectSql_mb.cmdParameters("@LineSource", "S", SqlDbType.NVarChar, 10));
                list.Add(new ConnectSql_mb.cmdParameters("@JobNo", JobNo, SqlDbType.NVarChar, 100));
                list.Add(new ConnectSql_mb.cmdParameters("@JobType", JobType, SqlDbType.NVarChar, 100));
                list.Add(new ConnectSql_mb.cmdParameters("@ChgCode", chgCode, SqlDbType.NVarChar, 100));
                dt = ConnectSql_mb.GetDataTable(sql, list);
                if (dt.Rows.Count <= 0)
                {
                    string    sql_chgCode = string.Format(@"select top 1 ChgcodeId,ChgcodeDes,GstP,GstTypeId,ChgTypeId from XXChgCode where ChgcodeId='{0}'", chgCode);
                    DataTable dt_chgCode  = ConnectSql.GetTab(sql_chgCode);
                    decimal   gst         = 0;
                    string    gstType     = "";
                    string    chgTypeId   = "";
                    if (dt_chgCode.Rows.Count > 0)
                    {
                        gst       = SafeValue.SafeDecimal(dt_chgCode.Rows[0]["GstP"]);
                        gstType   = SafeValue.SafeString(dt_chgCode.Rows[0]["GstTypeId"]);
                        chgTypeId = SafeValue.SafeString(dt_chgCode.Rows[0]["ChgTypeId"]);
                    }
                    sql  = string.Format(@"insert into job_cost (JobNo,JobType,ChgCode,ChgCodeDes,Price,Qty,CurrencyId,ExRate,LocAmt,LineSource,LineType,BillClass,ContNo,ContType,RowCreateUser,RowCreateTime,RowUpdateUser,RowUpdateTime,LineId,DocAmt,Gst,GstAmt,GstType)
values(@JobNo,@JobType,@ChgCode,@ChgCodeDes,@Price,@Qty,@CurrencyId,@ExRate,@LocAmt,@LineSource,@LineType,@BillClass,@ContainerNo,@ContainerType,@UserId,@DateTime,@UserId,@DateTime,0,@DocAmt,@Gst,@GstAmt,@GstType)");
                    list = new List <ConnectSql_mb.cmdParameters>();
                    list.Add(new ConnectSql_mb.cmdParameters("@LineType", "JOB", SqlDbType.NVarChar, 30));
                    list.Add(new ConnectSql_mb.cmdParameters("@BillClass", BillClass, SqlDbType.NVarChar, 30));
                    list.Add(new ConnectSql_mb.cmdParameters("@LineSource", "S", SqlDbType.NVarChar, 10));
                    list.Add(new ConnectSql_mb.cmdParameters("@JobNo", JobNo, SqlDbType.NVarChar, 100));
                    list.Add(new ConnectSql_mb.cmdParameters("@JobType", JobType, SqlDbType.NVarChar, 100));
                    list.Add(new ConnectSql_mb.cmdParameters("@ContainerNo", "", SqlDbType.NVarChar, 100));
                    list.Add(new ConnectSql_mb.cmdParameters("@ContainerType", "", SqlDbType.NVarChar, 100));

                    list.Add(new ConnectSql_mb.cmdParameters("@ChgCode", chgCode, SqlDbType.NVarChar, 100));
                    list.Add(new ConnectSql_mb.cmdParameters("@ChgCodeDes", chgCodeDes, SqlDbType.NVarChar, 300));
                    list.Add(new ConnectSql_mb.cmdParameters("@Price", price, SqlDbType.Decimal));
                    list.Add(new ConnectSql_mb.cmdParameters("@Qty", 1, SqlDbType.Int));
                    decimal amt    = SafeValue.ChinaRound(1 * SafeValue.SafeDecimal(price, 0), 2);
                    decimal gstAmt = SafeValue.ChinaRound((amt * SafeValue.SafeDecimal(gst, 0)), 2);
                    decimal docAmt = amt;
                    decimal locAmt = SafeValue.ChinaRound(docAmt * SafeValue.SafeDecimal(1, 1), 2);
                    list.Add(new ConnectSql_mb.cmdParameters("@LocAmt", locAmt, SqlDbType.Decimal));
                    list.Add(new ConnectSql_mb.cmdParameters("@CurrencyId", System.Configuration.ConfigurationManager.AppSettings["Currency"], SqlDbType.NVarChar, 100));
                    list.Add(new ConnectSql_mb.cmdParameters("@ExRate", 1, SqlDbType.Decimal));
                    string userId = HttpContext.Current.User.Identity.Name;
                    list.Add(new ConnectSql_mb.cmdParameters("@UserId", userId, SqlDbType.NVarChar, 100));
                    list.Add(new ConnectSql_mb.cmdParameters("@DateTime", DateTime.Now, SqlDbType.NVarChar, 100));
                    list.Add(new ConnectSql_mb.cmdParameters("@DocAmt", docAmt, SqlDbType.Decimal));
                    list.Add(new ConnectSql_mb.cmdParameters("@Gst", gst, SqlDbType.Decimal));
                    list.Add(new ConnectSql_mb.cmdParameters("@GstAmt", gstAmt, SqlDbType.Decimal));
                    list.Add(new ConnectSql_mb.cmdParameters("@GstType", gstType, SqlDbType.NVarChar));
                    ConnectSql_mb.ExecuteNonQuery(sql, list);
                }
            }
        }
Exemplo n.º 11
0
    protected string SaveNewSch(string id)
    {
        try
        {
            Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(JobSchedule), "Id='" + id + "'");
            JobSchedule jobSch = C2.Manager.ORManager.GetObject(query) as JobSchedule;
            string      issueN = "";
            JobSchedule job    = new JobSchedule();
            DateTime    dt     = DateTime.Now;
            issueN      = C2Setup.GetNextSchNo("", "Schedule", dt);
            job.JobDate = dt;

            job.JobStage         = jobSch.JobStage;
            job.JobType          = jobSch.JobType;
            job.Mode             = jobSch.Mode;
            job.ViaWh            = jobSch.ViaWh;
            job.StorageStartDate = new DateTime(1900, 1, 1);
            job.StorageFreeDays  = jobSch.StorageFreeDays; //new DateTime(1900,1,1);
            if (job.JobType == "Storage")
            {
                issueN    = "SR-" + issueN;
                job.ViaWh = "Normal";
            }
            if (job.JobType == "Outbound")
            {
                issueN   = "OB-" + issueN;
                job.Mode = "Lcl";
            }
            if (job.JobType == "Local Move")
            {
                issueN = "LM-" + issueN;
            }
            if (job.JobType == "Office Move")
            {
                issueN = "OM-" + issueN;
            }
            if (job.JobType == "Inbound")
            {
                issueN = "IB-" + issueN;
            }
            if (job.JobType == "Air")
            {
                issueN = "AR-" + issueN;
            }

            //Main Info
            job.CustomerId   = jobSch.CustomerId;
            job.CustomerName = jobSch.CustomerName;
            job.CustomerAdd  = jobSch.CustomerAdd;
            job.Postalcode   = jobSch.Postalcode;
            job.Contact      = jobSch.Contact;
            job.Tel          = jobSch.Tel;
            job.Email        = jobSch.Email;
            job.Fax          = jobSch.Fax;
            job.Remark       = jobSch.Remark;
            job.WorkStatus   = jobSch.WorkStatus;
            job.Currency     = jobSch.Currency;
            job.ExRate       = jobSch.ExRate;
            job.PayTerm      = jobSch.PayTerm;
            job.ExpiryDate   = jobSch.ExpiryDate;
            job.PackRmk      = jobSch.PackRmk;
            job.MoveRmk      = jobSch.MoveRmk;

            job.WareHouseId     = jobSch.WareHouseId;
            job.OriginPort      = jobSch.OriginPort;
            job.DestinationPort = jobSch.DestinationPort;
            job.OriginAdd       = jobSch.OriginAdd;
            job.DestinationAdd  = jobSch.DestinationAdd;
            job.Volumne         = jobSch.Volumne;
            job.ItemDes         = jobSch.ItemDes;
            job.VolumneRmk      = jobSch.VolumneRmk;
            job.HeadCount       = jobSch.HeadCount;

            job.PackDate         = jobSch.PackDate;
            job.StorageStartDate = jobSch.StorageStartDate;
            job.StorageFreeDays  = jobSch.StorageFreeDays;
            job.StorageTotalDays = jobSch.StorageTotalDays;
            job.TripNo           = jobSch.TripNo;
            job.MoveDate         = jobSch.MoveDate;
            job.Charges          = jobSch.Charges;
            job.EntryPort        = jobSch.EntryPort;
            job.Mode             = jobSch.Mode;
            job.Eta          = jobSch.Eta;
            job.TruckNo      = jobSch.TruckNo;
            job.OriginCity   = jobSch.OriginCity;
            job.DestCity     = jobSch.DestCity;
            job.OriginPostal = jobSch.OriginPostal;
            job.DestPostal   = jobSch.DestPostal;
            job.ServiceType  = jobSch.ServiceType;
            //Additional

            job.Item1       = jobSch.Item1;
            job.Item2       = jobSch.Item2;
            job.ItemDetail1 = jobSch.ItemDetail1;
            job.ItemDetail2 = jobSch.ItemDetail2;

            job.Item3      = jobSch.Item3;
            job.ItemValue3 = jobSch.ItemValue3;
            job.ItemData3  = jobSch.ItemData3;
            job.ItemPrice3 = jobSch.ItemPrice3;

            job.Item4       = jobSch.Item4;
            job.ItemDetail4 = jobSch.ItemDetail4;
            job.ItemPrice4  = jobSch.ItemPrice4;

            job.Item5      = jobSch.Item5;
            job.ItemValue5 = jobSch.ItemValue5;
            job.ItemPrice5 = jobSch.ItemPrice5;

            job.Item6       = jobSch.Item6;
            job.ItemDetail6 = jobSch.ItemDetail6;
            job.ItemPrice6  = jobSch.ItemPrice6;;

            job.Item7       = jobSch.Item7;
            job.ItemValue7  = jobSch.ItemValue7;
            job.ItemDetail7 = jobSch.ItemDetail7;
            job.ItemPrice7  = jobSch.ItemPrice7;

            job.Item8       = jobSch.Item8;
            job.ItemValue8  = jobSch.ItemValue8;
            job.ItemDetail8 = jobSch.ItemDetail8;
            job.ItemPrice8  = jobSch.ItemPrice8;

            job.Item9       = jobSch.Item9;
            job.ItemValue9  = jobSch.ItemValue9;
            job.ItemDetail9 = jobSch.ItemDetail9;
            job.ItemPrice9  = jobSch.ItemPrice9;

            job.Item10       = jobSch.Item10;
            job.ItemValue10  = jobSch.ItemValue10;
            job.ItemDetail10 = jobSch.ItemDetail10;
            job.ItemPrice10  = jobSch.ItemPrice10;

            job.Item11       = jobSch.Item11;
            job.ItemDetail11 = jobSch.ItemDetail11;

            job.Item12       = jobSch.Item12;
            job.ItemDetail12 = jobSch.ItemDetail12;

            job.Item13      = jobSch.Item13;
            job.ItemValue13 = jobSch.ItemValue13;
            job.ItemData13  = jobSch.ItemData13;

            job.Item14       = jobSch.Item14;
            job.ItemValue14  = jobSch.ItemValue14;
            job.ItemDetail14 = jobSch.ItemDetail14;
            job.ItemPrice14  = jobSch.ItemPrice14;

            job.Answer1    = jobSch.Answer1;
            job.Answer2    = jobSch.Answer2;
            job.Answer3    = jobSch.Answer3;
            job.Answer4    = jobSch.Answer4;
            job.WorkStatus = jobSch.WorkStatus;



            //Quotation
            job.Attention1 = jobSch.Attention1;
            job.Attention2 = jobSch.Attention2;
            job.Attention3 = jobSch.Attention3;
            job.Attention4 = jobSch.Attention4;
            job.Attention5 = jobSch.Attention5;
            job.DateTime2  = jobSch.DateTime2;
            job.DateTime1  = jobSch.DateTime1;
            job.DateTime3  = jobSch.DateTime3;
            job.DateTime4  = jobSch.DateTime4;
            //job.DateTime5 = jobSch.DateTime5;
            //job.DateTime6 = jobSch.DateTime6;
            //job.DateTime7 = jobSch.DateTime7;
            //job.DateTime8 = jobSch.DateTime8;
            job.Value1 = jobSch.Value1;
            job.Value2 = jobSch.Value2;
            job.Value3 = jobSch.Value3;
            job.Value4 = jobSch.Value4;
            //job.Value5 = jobSch.Value5;
            //job.Value6 = jobSch.Value6;
            //job.Value7 = jobSch.Value7;
            //job.Value8 = jobSch.Value8;
            job.Notes = jobSch.Notes;


            string userId = HttpContext.Current.User.Identity.Name;
            job.RefNo          = jobSch.RefNo;
            job.CreateBy       = userId;
            job.CreateDateTime = DateTime.Now;
            job.UpdateBy       = userId;
            job.UpdateDateTime = DateTime.Now;
            job.JobNo          = issueN;
            job.DateTime1      = DateTime.Now;
            job.CustomerName   = jobSch.CustomerName;
            job.OriginAdd      = jobSch.OriginAdd;
            job.DestinationAdd = jobSch.DestinationAdd;
            job.PackRmk        = jobSch.PackRmk;
            job.VolumneRmk     = jobSch.VolumneRmk;
            job.Contact        = jobSch.Contact;
            Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted);
            Manager.ORManager.PersistChanges(job);
            C2Setup.SetNextNo("", "Schedule", issueN, DateTime.Now);

            #region Item List
            string    sql = string.Format(@"SELECT  Id, RefNo, JobNo, ItemType, ItemName, ItemQty, ItemValue, ItemMark, ItemNote, CreateBy, CreateDateTime, 
                UpdateBy, UpdateDateTime FROM JobItemList where RefNo='{0}'", jobSch.JobNo);
            DataTable tab = ConnectSql.GetTab(sql);
            for (int i = 0; i < tab.Rows.Count; i++)
            {
                JobItemList list = new JobItemList();

                list.RefNo    = job.JobNo;
                list.ItemName = SafeValue.SafeString(tab.Rows[i]["ItemName"]);

                list.ItemNote       = SafeValue.SafeString(tab.Rows[i]["ItemNote"]);
                list.ItemMark       = SafeValue.SafeString(tab.Rows[i]["ItemMark"]);
                list.ItemQty        = SafeValue.SafeInt(tab.Rows[i]["ItemQty"], 0);
                list.ItemValue      = SafeValue.SafeDecimal(tab.Rows[i]["ItemValue"]);
                list.ItemType       = SafeValue.SafeString(tab.Rows[i]["ItemType"]);
                list.CreateBy       = EzshipHelper.GetUserName();
                list.CreateDateTime = DateTime.Now;
                list.JobNo          = SafeValue.SafeString(tab.Rows[i]["JobNo"]);
                Manager.ORManager.StartTracking(list, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(list);
            }
            #endregion

            #region JobMCST
            sql = string.Format(@"SELECT Id, RefNo, McstNo, McstDate1, McstDate2, States, McstRemark1, McstRemark2, Amount1, Amount2, CondoTel, 
                McstRemark3, CreateBy, CreateDateTime, UpdateBy, UpdateDateTime FROM JobMCST where RefNo='{0}'", jobSch.JobNo);
            DataTable tab_mcst = ConnectSql.GetTab(sql);
            for (int i = 0; i < tab_mcst.Rows.Count; i++)
            {
                JobMCST list = new JobMCST();
                list.RefNo          = job.JobNo;
                list.McstNo         = SafeValue.SafeString(tab_mcst.Rows[i]["McstNo"]);
                list.McstDate1      = SafeValue.SafeDate(tab_mcst.Rows[i]["McstDate1"], DateTime.Now);
                list.McstDate2      = SafeValue.SafeDate(tab_mcst.Rows[i]["McstDate2"], DateTime.Now);
                list.States         = SafeValue.SafeString(tab_mcst.Rows[i]["States"]);
                list.McstRemark1    = SafeValue.SafeString(tab_mcst.Rows[i]["McstRemark1"]);
                list.McstRemark2    = SafeValue.SafeString(tab_mcst.Rows[i]["McstRemark2"]);
                list.CreateBy       = SafeValue.SafeString(tab_mcst.Rows[i]["CreateBy"]);
                list.CreateDateTime = SafeValue.SafeDate(tab_mcst.Rows[i]["CreateDateTime"], DateTime.Now);
                list.UpdateBy       = SafeValue.SafeString(tab_mcst.Rows[i]["UpdateBy"]);
                list.UpdateDateTime = SafeValue.SafeDate(tab_mcst.Rows[i]["UpdateDateTime"], DateTime.Now);
                list.CondoTel       = SafeValue.SafeString(tab_mcst.Rows[i]["CondoTel"]);
                list.McstRemark3    = SafeValue.SafeString(tab_mcst.Rows[i]["McstRemark3"]);
                list.Amount1        = SafeValue.SafeDecimal(tab_mcst.Rows[i]["Amount1"]);
                list.Amount2        = SafeValue.SafeDecimal(tab_mcst.Rows[i]["Amount2"]);
                Manager.ORManager.StartTracking(list, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(list);
            }
            #endregion
            #region Materials
            sql = string.Format(@"SELECT Id, Description, Unit, RequisitionNew, RequisitionUsed, AdditionalNew, AdditionalUsed, AdditionalNew1, 
                AdditionalUsed1, AdditionalNew2, AdditionalUsed2, ReturnedNew, ReturnedUsed, TotalNew, TotalUsed, RefNo, 
                RequisitionNew1, RequisitionUsed1, RequisitionNew2, RequisitionUsed2 FROM Materials where RefNo='{0}'", jobSch.JobNo);
            DataTable tab_material = ConnectSql.GetTab(sql);
            for (int i = 0; i < tab_material.Rows.Count; i++)
            {
                Material list = new Material();
                list.RefNo            = job.JobNo;
                list.Description      = SafeValue.SafeString(tab_material.Rows[i]["Description"]);
                list.Unit             = SafeValue.SafeString(tab_material.Rows[i]["Unit"]);
                list.RequisitionNew   = SafeValue.SafeInt(tab_material.Rows[i]["RequisitionNew"], 0);
                list.RequisitionUsed  = SafeValue.SafeInt(tab_material.Rows[i]["RequisitionUsed"], 0);
                list.AdditionalNew    = SafeValue.SafeInt(tab_material.Rows[i]["AdditionalNew"], 0);
                list.AdditionalUsed   = SafeValue.SafeInt(tab_material.Rows[i]["AdditionalUsed"], 0);
                list.AdditionalNew1   = SafeValue.SafeInt(tab_material.Rows[i]["AdditionalNew1"], 0);
                list.AdditionalUsed1  = SafeValue.SafeInt(tab_material.Rows[i]["AdditionalUsed1"], 0);
                list.AdditionalNew2   = SafeValue.SafeInt(tab_material.Rows[i]["AdditionalNew2"], 0);
                list.AdditionalUsed2  = SafeValue.SafeInt(tab_material.Rows[i]["AdditionalUsed2"], 0);
                list.ReturnedNew      = SafeValue.SafeInt(tab_material.Rows[i]["ReturnedNew"], 0);
                list.ReturnedUsed     = SafeValue.SafeInt(tab_material.Rows[i]["ReturnedUsed"], 0);
                list.RequisitionNew1  = SafeValue.SafeInt(tab_material.Rows[i]["RequisitionNew1"], 0);
                list.RequisitionUsed1 = SafeValue.SafeInt(tab_material.Rows[i]["RequisitionUsed1"], 0);
                list.RequisitionNew2  = SafeValue.SafeInt(tab_material.Rows[i]["RequisitionNew2"], 0);
                list.RequisitionUsed2 = SafeValue.SafeInt(tab_material.Rows[i]["RequisitionUsed2"], 0);
                list.TotalNew         = SafeValue.SafeInt(tab_material.Rows[i]["TotalNew"], 0);
                list.TotalUsed        = SafeValue.SafeInt(tab_material.Rows[i]["TotalUsed"], 0);
                Manager.ORManager.StartTracking(list, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(list);
            }
            #endregion
            return(job.JobNo);
        }
        catch { }
        return("");
    }
Exemplo n.º 12
0
    protected void btn_CreateInv_Click(object sender, EventArgs e)
    {
        string   invNo    = "";
        string   mastType = "WH";
        DateTime dt       = DateTime.Today;
        bool     isNew    = false;
        int      docId    = 0;

        if (list.Count > 0)
        {
            XAArInvoice iv = null;
            for (int i = 0; i < list.Count; i++)
            {
                string  counterType = "AR-IV";
                string  partyId     = list[i].partyId;
                string  product     = list[i].doNo;
                string  doNo        = list[i].doNo;
                int     qty         = list[i].qty;
                decimal surcharge   = list[i].surcharge;
                string  sql_cost    = string.Format(@"select * from(select mast.DoNo,CONVERT(VARCHAR(10),mast.DoDate,110) as DoDate,cost.ChgCode as ChargeCode, 
ChgCodeDes as Description,CONVERT(int,CostQty) as Qty,CostPrice as Price,StatusCode,
isnull(((CostQty)*(isnull((CostPrice),0) )),0) as TotalAmt,dbo.fun_GetPartyName(mast.PartyId) AS PartyName,mast.PartyId,
0 as Surcharge,0 as SurchageAmt,JobType as DoType,CONVERT(decimal(10,6),(isnull((CostQty*CostPrice),0)*CostGst)) as GstAmt,
ISNULL((select count(SequenceId) from XAArInvoiceDet det where det.ChgCode=cost.ChgCode and det.MastRefNo=RefNo),0) as CostCnt,
isnull((select count(Id) from Wh_Costing where RefNo=mast.DoNo and JobType=mast.DoType),0) as CostDoCnt
 from Wh_Costing cost left join Wh_DO mast on RefNo=mast.DoNo and JobType=mast.DoType and StatusCode='CLS'
 ) as tab where CostCnt=0 and CostDoCnt>0 and TotalAmt>0 and DoNo='{0}'", doNo);
                string  sql         = string.Format(@"select top 1 det.DocNo from XAArInvoiceDet det inner join XAArInvoice mast on det.DocNo=mast.DocNo where det.MastRefNo='{0}' and InvType='HANDLING' and CancelInd='N' order by det.DocNo desc", doNo);
                invNo = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(sql));

                if (invNo.Length == 0)
                {
                    iv    = new XAArInvoice();
                    invNo = C2Setup.GetNextNo("", counterType, dt);
                    isNew = true;
                }
                else
                {
                    Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(XAArInvoice), "DocNo='" + invNo + "'");
                    iv    = C2.Manager.ORManager.GetObject(query) as XAArInvoice;
                    isNew = false;
                }
                iv.DocType     = "IV";
                iv.DocDate     = dt;
                iv.DocNo       = invNo;
                iv.PartyTo     = partyId;
                iv.CurrencyId  = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                iv.ExRate      = 1;
                iv.AcCode      = EzshipHelper.GetAccApCode(iv.PartyTo, iv.CurrencyId);
                iv.AcSource    = "DB";
                iv.Description = "";
                iv.Term        = "CASH";

                string[] currentPeriod = EzshipHelper.GetAccPeriod(iv.DocDate);
                iv.AcYear   = SafeValue.SafeInt(currentPeriod[1], iv.DocDate.Year);
                iv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], iv.DocDate.Month);

                iv.MastRefNo   = "";
                iv.JobRefNo    = "";
                iv.MastType    = mastType;
                iv.DocAmt      = 0;
                iv.LocAmt      = 0;
                iv.BalanceAmt  = 0;
                iv.CancelDate  = new DateTime(1900, 1, 1);
                iv.CancelInd   = "N";
                iv.DocDueDate  = dt;
                iv.ExportInd   = "N";
                iv.SpecialNote = "";
                iv.UserId      = EzshipHelper.GetUserName();
                iv.EntryDate   = DateTime.Now;
                iv.InvType     = "HANDLING";
                if (isNew)
                {
                    C2.Manager.ORManager.StartTracking(iv, Wilson.ORMapper.InitialState.Inserted);
                    C2.Manager.ORManager.PersistChanges(iv);
                    C2Setup.SetNextNo(iv.DocType, counterType, invNo, iv.DocDate);
                }
                else
                {
                    Manager.ORManager.StartTracking(iv, Wilson.ORMapper.InitialState.Updated);
                    Manager.ORManager.PersistChanges(iv);
                }

                try
                {
                    DataTable tab_Cost = ConnectSql.GetTab(sql_cost);
                    for (int a = 0; a < tab_Cost.Rows.Count; a++)
                    {
                        C2.XAArInvoiceDet det = new C2.XAArInvoiceDet();
                        det.DocId     = iv.SequenceId;
                        det.DocLineNo = i + 1;
                        det.DocNo     = invNo;
                        det.DocType   = "IV";
                        det.AcCode    = SafeValue.SafeString(ConnectSql.ExecuteScalar(string.Format("select ArCode from ref_product where Code='{0}'", product)), System.Configuration.ConfigurationManager.AppSettings["ItemArCode"]);
                        det.AcSource  = "CR";
                        det.MastRefNo = doNo;
                        det.JobRefNo  = "";
                        det.MastType  = mastType;
                        det.SplitType = "";


                        det.ChgCode = SafeValue.SafeString(tab_Cost.Rows[a]["ChargeCode"]);;
                        det.ChgDes1 = SafeValue.SafeString(tab_Cost.Rows[a]["Description"]);
                        det.ChgDes2 = "";
                        det.ChgDes3 = "";

                        det.Price    = SafeValue.SafeDecimal(tab_Cost.Rows[a]["Price"]);
                        det.Qty      = SafeValue.SafeInt(tab_Cost.Rows[a]["Qty"], 0);
                        det.Unit     = "";
                        det.Currency = iv.CurrencyId;
                        det.ExRate   = 1;
                        det.Gst      = 0;
                        if (det.ExRate == 0)
                        {
                            det.ExRate = 1;
                        }
                        if (det.Gst > 0)
                        {
                            det.GstType = "S";
                        }
                        else if (det.Currency == System.Configuration.ConfigurationManager.AppSettings["Currency"])
                        {
                            det.GstType = "E";
                        }
                        else
                        {
                            det.GstType = "Z";
                        }
                        decimal amt    = SafeValue.ChinaRound(det.Qty * det.Price, 2);
                        decimal gstAmt = SafeValue.ChinaRound((amt * det.Gst), 2);
                        decimal docAmt = amt + gstAmt;
                        decimal locAmt = SafeValue.ChinaRound(docAmt * det.ExRate, 2);
                        det.GstAmt   = gstAmt;
                        det.DocAmt   = docAmt;
                        det.LocAmt   = locAmt;
                        det.OtherAmt = 0;

                        C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                        C2.Manager.ORManager.PersistChanges(det);
                        if (surcharge != 0)
                        {
                            det.ChgCode = "HANDLE";
                            det.Qty     = 1;
                            det.Price   = surcharge;
                            sql         = string.Format(@"select * from XXChgCode where ChgcodeId='{0}'", det.ChgCode);
                            DataTable tab = ConnectSql.GetTab(sql);
                            for (int j = 0; j < tab.Rows.Count; j++)
                            {
                                det.AcCode  = SafeValue.SafeString(tab.Rows[j]["ArCode"]);
                                det.ChgDes1 = SafeValue.SafeString(tab.Rows[j]["ChgcodeDes"]);
                                det.GstType = SafeValue.SafeString(tab.Rows[j]["GstTypeId"]);
                                det.Gst     = SafeValue.SafeDecimal(tab.Rows[j]["GstP"]);
                            }


                            amt    = SafeValue.ChinaRound(det.Qty * det.Price, 2);
                            gstAmt = SafeValue.ChinaRound((amt * det.Gst), 2);

                            docAmt = amt + gstAmt;

                            locAmt     = SafeValue.ChinaRound(docAmt * det.ExRate, 2);
                            det.GstAmt = gstAmt;
                            det.DocAmt = docAmt;
                            det.LocAmt = locAmt;
                            C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                            C2.Manager.ORManager.PersistChanges(det);
                        }
                        docId = iv.SequenceId;
                    }
                }
                catch
                {
                }
                UpdateMaster(docId);
            }
            // string script = string.Format('<script type="text/javascript" > parent.navTab.openTab("{0}","/opsAccount/ArInvoiceEdit.aspx?no="{0}"",{title:'', fresh:false, external:true});</script>", invNo);
            //string script = string.Format("<script type='text/javascript' >alert('{0}');</script>", refNo);
            //Response.Clear();
            //Response.Write(script);
            //<a href='javascript: parent.navTab.openTab("<%# Eval("DoNo") %>","/Modules/WareHouse/Job/DoOutEdit.aspx?no=<%# Eval("DoNo") %>",{title:"<%# Eval("DoNo") %>", fresh:false, external:true});'><%# Eval("DoNo") %></a>
            Response.Redirect("/opsAccount/ArInvoiceEdit.aspx?no=" + invNo);
        }
    }
Exemplo n.º 13
0
 protected void grid_InvDet_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
 {
     e.Values["SequenceId"] = SafeValue.SafeString(e.Values["SequenceId"]);
 }
Exemplo n.º 14
0
    protected void btn_search_Click(object sender, EventArgs e)
    {
        string From   = txt_search_dateFrom.Date.ToString("yyyyMMdd");
        string To     = txt_search_dateTo.Date.AddDays(1).ToString("yyyyMMdd");
        string ContNo = txt_search_ContNo.Text;
        //bool ContStatus_N = cb_ContStatus1.Checked;
        //bool ContStatus_I = cb_ContStatus2.Checked;
        //bool ContStatus_CL = cb_ContStatus3.Checked;
        //bool ContStatus_R = cb_ContStatus4.Checked;
        //bool ContStatus_E = cb_ContStatus5.Checked;
        //bool ContStatus_C = cb_ContStatus6.Checked;
        //bool ContStatus_UnC = cb_ContStatus7.Checked;

        bool cs_New        = cb_cs_New.Checked;
        bool cs_Completed  = cb_cs_Completed.Checked;
        bool cs_Uncomplete = false;// cb_cs_Uncomplete.Checked;
        bool cs_Import     = cb_cs_Import.Checked;
        bool cs_Return     = cb_cs_Return.Checked;
        bool cs_Collection = cb_cs_Collection.Checked;
        bool cs_Export     = cb_cs_Export.Checked;
        bool cs_WHSMT      = cb_cs_WHSMT.Checked;
        bool cs_WHSLD      = cb_cs_WHSLD.Checked;
        bool cs_CustomerMT = cb_cs_CustomerMT.Checked;
        bool cs_CustomerLD = cb_cs_CustomerLD.Checked;

        string JobNo       = txt_search_jobNo.Text;
        string JobType     = search_JobType.Text;
        string Vessel      = txt_Vessel.Text;
        string Client      = btn_ClientId.Text;
        string NextTrip    = SafeValue.SafeString(search_NextTrip.Value);
        string subContract = SafeValue.SafeString(cbb_subContract.Value, "ALL");
        //string ClientName = info["ClientName"].ToString();

        List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();

        list.Add(new ConnectSql_mb.cmdParameters("@DateFrom", From, SqlDbType.NVarChar, 8));
        list.Add(new ConnectSql_mb.cmdParameters("@DateTo", To, SqlDbType.NVarChar, 8));
        list.Add(new ConnectSql_mb.cmdParameters("@ContNo", "%" + ContNo, SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@JobNo", "%" + JobNo + "%", SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@JobType", JobType, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@Vessel", Vessel, SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@Client", Client, SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@NextTrip", NextTrip, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@subContract", subContract, SqlDbType.NVarChar, 10));



        string sql       = string.Format(@"select job.Id,det1.Id as ContId,job.JobNo,job.StatusCode as JobStatus,job.JobDate,det1.YardAddress as Depot,job.ClientRefNo,
job.PermitNo,job.Remark,job.SpecialInstruction,det1.ContainerNo,det1.SealNo,det1.ContainerType,job.EtaDate,job.EtaTime,job.EtdDate,
det1.UrgentInd,job.OperatorCode,job.CarrierBkgNo,det1.oogInd,det1.CfsStatus,det1.DischargeCell,IsTrucking,IsWarehouse,
job.Pol,job.Pod,job.Vessel,job.Voyage,job.PickupFrom,job.DeliveryTo,det1.ScheduleDate,det1.StatusCode ,det1.F5Ind,det1.EmailInd,det1.WarehouseStatus,
(select top 1 Code from XXParty where PartyId=job.ClientId) as client,(select top 1 code from XXParty where PartyId=job.HaulierId) as Haulier,
job.Terminalcode,job.JobType,det1.PortnetStatus,det1.Permit,job.Contractor,job.ClientContact,
(select '<span class='''+det2.Statuscode+'''>'+TripCode+'</span>' from CTM_JobDet2 as det2 where Det1Id=det1.Id for xml path('')) as trips,
datediff(hour,isnull((select top 1 convert(nvarchar(8),det2.FromDate,112)+' '+det2.FromTime
from ctm_jobdet2 as det2 where det2.Det1Id=det1.Id and (det2.Statuscode='S' or det2.Statuscode='C') order by det2.FromDate,det2.FromTime),
convert(nvarchar(8),getdate(),112)+' '+convert(nvarchar(5),getdate(),114)),
case when det1.StatusCode='Completed' then isnull((select top 1 convert(nvarchar(8),det2.ToDate,112)+' '+det2.ToTime
from ctm_jobdet2 as det2 where det2.Det1Id=det1.Id and det2.Statuscode='C' order by det2.ToDate desc,det2.ToTime desc),
convert(nvarchar(8),getdate(),112)+' '+convert(nvarchar(5),getdate(),114)) else getdate() end)  as hr,
isnull((select ','+det2.Statuscode+':'+TripCode from CTM_JobDet2 as det2 where Det1Id=det1.Id for xml path('')),'')+',' as str_trips,
isnull((select top 1 det2.Statuscode+':'+TripCode from CTM_JobDet2 as det2 where det2.Det1Id=det1.Id order by det2.Id desc),'') as curTrip
from CTM_Job as job left outer join CTM_JobDet1 as det1 on job.JobNo=det1.JobNo");
        string sql_where = "";

        if (ContNo.Length > 0)
        {
            sql_where = GetWhere(sql_where, "det1.ContainerNo like @ContNo");
        }
        if (JobNo.Length > 0)
        {
            sql_where = GetWhere(sql_where, "job.JobNo like @JobNo");
        }
        string sql_part1 = string.Format(@"select *,(case JobType when 'IMP' then (case when StatusCode='New' then 'IMP' when StatusCode='Import' and curTrip<>'C:IMP' then 'IMP' when StatusCode='WHS-MT' then 'RET' when StatusCode='Return' and curTrip<>'C:RET' then 'RET' else '' end) 
when 'EXP' then (case when StatusCode='New' then 'COL' when StatusCode='Collection' and curTrip<>'C:COL'then 'COL' when StatusCode='WHS-LD' then 'EXP' when StatusCode='Export' and curTrip<>'C:EXP' then 'EXP' else '' end) 
else ''  end) as NextTrip
from(");
        string sql_part2 = string.Format(@") as temp");

        if (sql_where.Equals(""))
        {
            //sql_where = " datediff(d,@DateFrom,det1.ScheduleDate)>=0 and datediff(d,@DateTo,det1.ScheduleDate)<=0";
            sql_where = " @DateFrom<=det1.ScheduleDate and @DateTo>det1.ScheduleDate";
            if (!cs_Uncomplete)
            {
                string sql_where_ContStatus = "";
                if (cs_New)
                {
                    sql_where_ContStatus += (sql_where_ContStatus.Equals("") ? "" : " or ") + "det1.StatusCode='New'";
                }
                if (cs_Completed)
                {
                    sql_where_ContStatus += (sql_where_ContStatus.Equals("") ? "" : " or ") + "det1.StatusCode='Completed'";
                }
                if (cs_Import)
                {
                    sql_where_ContStatus += (sql_where_ContStatus.Equals("") ? "" : " or ") + "det1.StatusCode='Import'";
                }
                if (cs_Return)
                {
                    sql_where_ContStatus += (sql_where_ContStatus.Equals("") ? "" : " or ") + "det1.StatusCode='Return'";
                }
                if (cs_Collection)
                {
                    sql_where_ContStatus += (sql_where_ContStatus.Equals("") ? "" : " or ") + "det1.StatusCode='Collection'";
                }
                if (cs_Export)
                {
                    sql_where_ContStatus += (sql_where_ContStatus.Equals("") ? "" : " or ") + "det1.StatusCode='Export'";
                }
                //================== warhouse
                if (cs_WHSMT)
                {
                    sql_where_ContStatus += (sql_where_ContStatus.Equals("") ? "" : " or ") + "det1.StatusCode='WHS-MT'";
                }
                if (cs_WHSLD)
                {
                    sql_where_ContStatus += (sql_where_ContStatus.Equals("") ? "" : " or ") + "det1.StatusCode='WHS-LD'";
                }
                if (cs_CustomerMT)
                {
                    sql_where_ContStatus += (sql_where_ContStatus.Equals("") ? "" : " or ") + "det1.StatusCode='Customer-MT'";
                }
                if (cs_CustomerLD)
                {
                    sql_where_ContStatus += (sql_where_ContStatus.Equals("") ? "" : " or ") + "det1.StatusCode='Customer-LD'";
                }
                //===================
                if (!sql_where_ContStatus.Equals(""))
                {
                    sql_where = GetWhere(sql_where, "(" + sql_where_ContStatus + ")");
                }
            }
            if (Vessel.Length > 0)
            {
                sql_where = GetWhere(sql_where, "job.Vessel=@Vessel");
            }
            if (JobType.Length > 0 && !JobType.Equals("ALL"))
            {
                sql_where = GetWhere(sql_where, "job.JobType=@JobType");
            }
            if (Client.Length > 0)
            {
                sql_where = GetWhere(sql_where, "job.clientId=@Client");
            }
            if (subContract.Length > 0 && subContract != "ALL")
            {
                sql_where = GetWhere(sql_where, "job.Contractor=@subContract");
            }


            sql = sql_part1 + sql + " where job.JobType in ('IMP','EXP','LOC')  and " + sql_where + sql_part2;
            if (NextTrip.Length > 0 && !NextTrip.Equals("ALL"))
            {
                sql = "select * from (" + sql + ") as temp where NextTrip=@NextTrip order by EtaDate,JobNo,Id,StatusCode desc, JobDate asc";
            }
            else
            {
                if (cs_Uncomplete)
                {
                    sql = "select * from (" + sql + ") as temp where StatusCode<>'Completed' and ((JobType='IMP' and CHARINDEX(',C:RET,',str_trips)>0) or (JobType='EXP' and CHARINDEX(',C:EXP,',str_trips)>0)) order by EtaDate,JobNo,Id,StatusCode desc, JobDate asc";
                }
                else
                {
                    sql += " order by EtaDate,JobNo,Id,StatusCode desc, JobDate asc";
                }
            }
        }
        else
        {
            sql  = sql_part1 + sql + " where job.JobType in ('IMP','EXP','LOC')  and " + sql_where + sql_part2;
            sql += " order by EtaDate,JobNo,Id,StatusCode desc, JobDate asc";
        }
        DataTable dt = ConnectSql_mb.GetDataTable(sql, list);

        //throw new Exception(sql.ToString());
        this.grid_Transport.DataSource = dt;
        this.grid_Transport.DataBind();
    }
Exemplo n.º 15
0
    public void Crane_JobEdit_Save(string info)
    {
        JObject job = (JObject)JsonConvert.DeserializeObject(HttpUtility.UrlDecode(Server.UrlDecode(info)));
        List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();

        ConnectSql_mb.cmdParameters cpar = null;
        string  status     = "0";
        string  context    = Common.StringToJson("");
        string  ByUser     = job["ByUser"].ToString();
        decimal OtHourType = SafeValue.SafeDecimal(job["OverTime"]);
        string  sql        = string.Format(@"update CTM_JobDet2 set TowheadCode=@TowheadCode,Remark1=@Remark1,ToCode=@ToCode,DriverCode=@DriverCode,UpdateUser=@ByUser,UpdateTime=GetDate(),OtHour=@OtHour
where Id=@Id");

        #region params
        cpar = new ConnectSql_mb.cmdParameters("@Id", job["Id"], SqlDbType.Int);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@Remark1", job["Remark1"], SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@TowheadCode", job["TowheadCode"], SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@DriverCode", job["DriverCode"], SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ToCode", job["ToCode"], SqlDbType.NVarChar, 300);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ByUser", ByUser, SqlDbType.NVarChar, 20);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@OtHour", SafeValue.SafeDecimal(job["OtHour"]), SqlDbType.Decimal);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@OtHourType", OtHourType, SqlDbType.Decimal);
        list.Add(cpar);
        #endregion

        if (ConnectSql_mb.ExecuteNonQuery(sql, list).status)
        {
            status = "1";

            Dictionary <string, decimal> d = new Dictionary <string, decimal>();
            //d.Add("Trip", SafeValue.SafeDecimal(job["Trip"], 0));
            d.Add("OverTime", SafeValue.SafeDecimal(job["OverTime"], 0));
            //d.Add("Standby", SafeValue.SafeDecimal(job["Standby"], 0));
            //d.Add("PSA", SafeValue.SafeDecimal(job["PSA"], 0));

            //d.Add("OverTime", (OtHourType.Length > 0 ? 1 : 0));
            C2.CtmJobDet2.Incentive_Save(SafeValue.SafeInt(job["Id"], 0), d);
            d = new Dictionary <string, decimal>();
            d.Add("EXPENSE", SafeValue.SafeDecimal(job["EXPENSE"], 0));
            //d.Add("DHC", SafeValue.SafeDecimal(job["DHC"], 0));
            //d.Add("WEIGHING", SafeValue.SafeDecimal(job["WEIGHING"], 0));
            //d.Add("WASHING", SafeValue.SafeDecimal(job["WASHING"], 0));
            //d.Add("REPAIR", SafeValue.SafeDecimal(job["REPAIR"], 0));
            //d.Add("DETENTION", SafeValue.SafeDecimal(job["DETENTION"], 0));
            //d.Add("DEMURRAGE", SafeValue.SafeDecimal(job["DEMURRAGE"], 0));
            //d.Add("LIFT_ON_OFF", SafeValue.SafeDecimal(job["LIFT_ON_OFF"], 0));
            //d.Add("C_SHIPMENT", SafeValue.SafeDecimal(job["C_SHIPMENT"], 0));
            //d.Add("EMF", SafeValue.SafeDecimal(job["EMF"], 0));
            //d.Add("OTHER", SafeValue.SafeDecimal(job["OTHER"], 0));
            C2.CtmJobDet2.Claims_Save(SafeValue.SafeInt(job["Id"], 0), d);


            //===========log
            C2.CtmJobEventLog lg = new C2.CtmJobEventLog();
            lg.Platform_isMobile();
            lg.Controller = SafeValue.SafeString(job["user"]);
            lg.Lat        = SafeValue.SafeString(job["Lat"]);
            lg.Lng        = SafeValue.SafeString(job["Lng"]);
            //lg.ActionLevel_isTRIP(SafeValue.SafeInt(job["Id"], 0));
            //lg.Remark = "Trip update";
            lg.setActionLevel(SafeValue.SafeInt(job["Id"], 0), CtmJobEventLogRemark.Level.Trip, 3);
            lg.log();
        }
        Common.WriteJsonP(status, context);
    }
Exemplo n.º 16
0
    protected void grid_Cont_RowUpdated(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e)
    {
        ASPxGridView grd = (sender as ASPxGridView) as ASPxGridView;

        updateJob_By_Date(SafeValue.SafeString(grd.GetMasterRowKeyValue(), "0"));
        if (SafeValue.SafeString(e.NewValues["ContainerNo"]) != SafeValue.SafeString(e.OldValues["ContainerNo"]))
        {
            string sql = string.Format("Update ctm_JobDet2 set ContainerNo='{1}' where Det1Id='{0}'", e.Keys["Id"], SafeValue.SafeString(e.NewValues["ContainerNo"]));
            ConnectSql.ExecuteSql(sql);
        }
    }
Exemplo n.º 17
0
    public void Crane_JobView_PODSave(string info)
    {
        JObject job            = (JObject)JsonConvert.DeserializeObject(HttpUtility.UrlDecode(Server.UrlDecode(info)));
        int     tripId         = SafeValue.SafeInt(job["Id"], 0);
        string  BillingRemark  = job["BillingRemark"].ToString();
        string  DeliveryRemark = job["DeliveryRemark"].ToString();
        string  Satisfaction   = job["Satisfaction"].ToString();
        string  FromDate       = job["FromDate"].ToString();
        string  FromTime       = job["FromTime"].ToString();
        string  ToDate         = job["ToDate"].ToString();
        string  ToTime         = job["ToTime"].ToString();
        decimal OtHour         = SafeValue.SafeDecimal(job["OtHour"], 0);
        int     epodTrip       = SafeValue.SafeInt(job["epodTrip"], 0);
        string  epodCB1        = SafeValue.SafeString(job["epodCB1"], "No");
        string  epodCB2        = SafeValue.SafeString(job["epodCB2"], "No");
        string  epodCB3        = SafeValue.SafeString(job["epodCB3"], "No");
        string  epodCB4        = SafeValue.SafeString(job["epodCB4"], "No");
        string  epodCB5        = SafeValue.SafeString(job["epodCB5"], "No");
        string  epodCB6        = SafeValue.SafeString(job["epodCB6"], "No");
        int     ManPowerNo     = SafeValue.SafeInt(job["ManPowerNo"], 0);
        string  ExcludeLunch   = SafeValue.SafeString(job["ExcludeLunch"]);

        string epodSignedBy   = SafeValue.SafeString(job["epodSignedBy"]);
        string DeliveryResult = SafeValue.SafeString(job["DeliveryResult"]);
        string epodHardCopy   = SafeValue.SafeString(job["epodHardCopy"]);
        string context        = Common.StringToJson("");

        string sql = string.Format(@"update CTM_JobDet2 set BillingRemark=@BillingRemark,DeliveryRemark=@DeliveryRemark,Satisfaction=@Satisfaction,PodType='C',
FromDate=@FromDate,FromTime=@FromTime,ToDate=@ToDate,ToTime=@ToTime,OtHour=@OtHour,TotalHour=@epodTrip,epodSignedBy=@epodSignedBy,
epodCB1=@epodCB1,epodCB2=@epodCB2,epodCB3=@epodCB3,epodCB4=@epodCB4,epodCB5=@epodCB5,epodCB6=@epodCB6,ManPowerNo=@ManPowerNo,ExcludeLunch=@ExcludeLunch,DeliveryResult=@DeliveryResult,epodHardCopy=@epodHardCopy 
where Id=@tripId");
        List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();

        list.Add(new ConnectSql_mb.cmdParameters("@tripId", tripId, SqlDbType.Int));
        list.Add(new ConnectSql_mb.cmdParameters("@BillingRemark", BillingRemark, SqlDbType.NVarChar, 300));
        list.Add(new ConnectSql_mb.cmdParameters("@DeliveryRemark", DeliveryRemark, SqlDbType.NVarChar, 300));
        list.Add(new ConnectSql_mb.cmdParameters("@Satisfaction", Satisfaction, SqlDbType.NVarChar, 30));
        list.Add(new ConnectSql_mb.cmdParameters("@FromDate", FromDate, SqlDbType.NVarChar, 8));
        list.Add(new ConnectSql_mb.cmdParameters("@FromTime", FromTime, SqlDbType.NVarChar, 5));
        list.Add(new ConnectSql_mb.cmdParameters("@ToDate", ToDate, SqlDbType.NVarChar, 8));
        list.Add(new ConnectSql_mb.cmdParameters("@ToTime", ToTime, SqlDbType.NVarChar, 5));
        list.Add(new ConnectSql_mb.cmdParameters("@OtHour", OtHour, SqlDbType.Decimal));
        list.Add(new ConnectSql_mb.cmdParameters("@epodTrip", epodTrip, SqlDbType.Int));
        list.Add(new ConnectSql_mb.cmdParameters("@epodSignedBy", epodSignedBy, SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@epodCB1", epodCB1, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@epodCB2", epodCB2, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@epodCB3", epodCB3, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@epodCB4", epodCB4, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@epodCB5", epodCB5, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@epodCB6", epodCB6, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@ManPowerNo", ManPowerNo, SqlDbType.Int));
        list.Add(new ConnectSql_mb.cmdParameters("@ExcludeLunch", ExcludeLunch, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@DeliveryResult", DeliveryResult, SqlDbType.NVarChar, 300));
        list.Add(new ConnectSql_mb.cmdParameters("@epodHardCopy", epodHardCopy, SqlDbType.NVarChar, 10));
        ConnectSql_mb.sqlResult result = ConnectSql_mb.ExecuteNonQuery(sql, list);
        if (result.status)
        {
            C2.CtmJobEventLog lg = new C2.CtmJobEventLog();
            lg.Platform_isMobile();
            lg.Controller = SafeValue.SafeString(job["user"]);
            lg.Lat        = SafeValue.SafeString(job["Lat"]);
            lg.Lng        = SafeValue.SafeString(job["Lng"]);
            //lg.ActionLevel_isTRIP(tripId);
            //lg.Remark = "Submit e-POD";
            lg.setActionLevel(tripId, CtmJobEventLogRemark.Level.Trip, 5);
            lg.log();

            if (!ePOD_SendEmail(tripId))
            {
                context = Common.StringToJson("Submit successful, but send false");
            }
        }
        Common.WriteJsonP(result.status, context);
    }
Exemplo n.º 18
0
    protected void grid_Trip_RowUpdated(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e)
    {
        ASPxGridView grd = (sender as ASPxGridView) as ASPxGridView;

        updateJob_By_Date(SafeValue.SafeString(grd.GetMasterRowKeyValue(), "0"));
    }
Exemplo n.º 19
0
    public void Crane_AddNew(string info)
    {
        JObject job           = (JObject)JsonConvert.DeserializeObject(HttpUtility.UrlDecode(Server.UrlDecode(info)));
        string  JobNo         = job["JobNo"].ToString();
        string  TowheadCode   = job["TowheadCode"].ToString();
        string  BookingDate   = job["BookingDate"].ToString();
        string  BookingTime   = job["BookingTime"].ToString();
        string  BookingTime2  = job["BookingTime2"].ToString();
        string  DriverCode    = job["DriverCode"].ToString();
        string  BookingRemark = job["BookingRemark"].ToString();
        string  ByUser        = job["ByUser"].ToString();

        string ToCode = "";
        string Remark = "";
        string sql    = string.Format(@"select DeliveryTo,SpecialInstruction from ctm_job where JobNo=@JobNo");
        List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();

        list.Add(new ConnectSql_mb.cmdParameters("@JobNo", JobNo, SqlDbType.NVarChar, 100));
        DataTable dt = ConnectSql_mb.GetDataTable(sql, list);

        if (dt.Rows.Count == 1)
        {
            ToCode = dt.Rows[0]["DeliveryTo"].ToString();
            Remark = dt.Rows[0]["SpecialInstruction"].ToString();
        }


        sql = string.Format(@"insert into CTM_JobDet2 (JobNo,ContainerNo,DriverCode,TowheadCode,ChessisCode,FromCode,FromDate,FromTime,ToCode,ToDate,ToTime,Statuscode,
BayCode,SubletFlag,StageCode,StageStatus,TripCode,Overtime,OverDistance,FromParkingLot,BookingDate,BookingTime,BookingTime2,BookingRemark,
ByUser,CreateUser,UpdateUser,CreateTime,UpdateTime,Remark) values 
(@JobNo,'',@DriverCode,@TowheadCode,'',@FromCode,@FromDate,@FromTime,@ToCode,@FromDate,@FromTime,'P',
'','N','','',@TripCode,'Normal','N',@FromParkingLot,@BookingDate,@BookingTime,@BookingTime2,@BookingRemark,
@ByUser,@ByUser,@ByUser,getdate(),getdate(),@Remark)
select @@Identity");
        list.Add(new ConnectSql_mb.cmdParameters("@DriverCode", DriverCode, SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@TowheadCode", TowheadCode, SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@FromCode", "", SqlDbType.NVarChar, 300));
        list.Add(new ConnectSql_mb.cmdParameters("@FromDate", "19000101", SqlDbType.NVarChar, 8));
        list.Add(new ConnectSql_mb.cmdParameters("@FromTime", "00:00", SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@BookingDate", BookingDate, SqlDbType.NVarChar, 8));
        list.Add(new ConnectSql_mb.cmdParameters("@BookingTime", BookingTime, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@BookingTime2", BookingTime2, SqlDbType.NVarChar, 10));
        list.Add(new ConnectSql_mb.cmdParameters("@ToCode", ToCode, SqlDbType.NVarChar, 300));
        list.Add(new ConnectSql_mb.cmdParameters("@TripCode", "CRA", SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@FromParkingLot", "", SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@BookingRemark", BookingRemark, SqlDbType.NVarChar, 100));
        list.Add(new ConnectSql_mb.cmdParameters("@ByUser", ByUser, SqlDbType.NVarChar, 20));
        list.Add(new ConnectSql_mb.cmdParameters("@Remark", Remark, SqlDbType.NVarChar, 300));
        ConnectSql_mb.sqlResult result = ConnectSql_mb.ExecuteScalar(sql, list);

        if (result.status)
        {
            //===========log
            C2.CtmJobEventLog lg = new C2.CtmJobEventLog();
            lg.Platform_isMobile();
            lg.Controller = SafeValue.SafeString(job["user"]);
            lg.Lat        = SafeValue.SafeString(job["Lat"]);
            lg.Lng        = SafeValue.SafeString(job["Lng"]);
            //lg.ActionLevel_isTRIP(SafeValue.SafeInt(result.context, 0));
            //lg.Remark = "Trip Add New";
            lg.setActionLevel(SafeValue.SafeInt(result.context, 0), CtmJobEventLogRemark.Level.Trip, 1);
            lg.log();
        }
        Common.WriteJsonP(result.status, Common.StringToJson(result.context));
    }
Exemplo n.º 20
0
    protected void Grid1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        e.NewValues["Remark"]        = Helper.Safe.SafeString(e.NewValues["Remark"]).Trim();
        e.NewValues["RowUpdateUser"] = HttpContext.Current.User.Identity.Name;
        e.NewValues["RowUpdateTime"] = DateTime.Now;
        e.NewValues["LineStatus"]    = Helper.Safe.SafeString(e.NewValues["LineStatus"]).Trim();
        e.NewValues["Unit"]          = Helper.Safe.SafeString(e.NewValues["Unit"]).Trim();
        e.NewValues["ContType"]      = Helper.Safe.SafeString(e.NewValues["ContType"]).Trim();
        if (Helper.Safe.SafeString(e.NewValues["ContType"]).Trim() != "")
        {
            e.NewValues["ContSize"] = Helper.Safe.SafeString(e.NewValues["ContType"]).Trim().Substring(0, 2);
        }
        else
        {
            e.NewValues["ContSize"] = Helper.Safe.SafeString(e.NewValues["ContSize"]).Trim();
        }
        e.NewValues["Remark"]    = Helper.Safe.SafeString(e.NewValues["Remark"]).Trim();
        e.NewValues["BillScope"] = Helper.Safe.SafeString(e.NewValues["BillScope"]).Trim();
        e.NewValues["BillType"]  = Helper.Safe.SafeString(e.NewValues["BillType"]).Trim();
        e.NewValues["BillClass"] = Helper.Safe.SafeString(e.NewValues["BillClass"]).Trim();
        ASPxGridView   grid        = (sender as ASPxGridView) as ASPxGridView;
        ASPxButtonEdit txt_ChgCode = grid.FindEditRowCellTemplateControl(null, "txt_Line_ChgCode") as ASPxButtonEdit;
        string         sql         = string.Format(@"select ChgcodeDes from XXChgCode where ChgcodeId='{0}'", SafeValue.SafeString(txt_ChgCode.Value));
        string         chgcodeDes  = SafeValue.SafeString(ConnectSql.ExecuteScalar(sql));

        if (SafeValue.SafeString(e.NewValues["ChgCodeDe"]) == "")
        {
            e.NewValues["ChgCodeDe"] = chgcodeDes;
        }
        e.NewValues["ChgCode"]     = SafeValue.SafeString(txt_ChgCode.Value);
        e.NewValues["ChgCodeDe"]   = SafeValue.SafeString(e.NewValues["ChgCodeDe"]);
        e.NewValues["SkuClass"]    = Helper.Safe.SafeString(e.NewValues["SkuClass"]).Trim();
        e.NewValues["SkuUnit"]     = Helper.Safe.SafeString(e.NewValues["SkuUnit"]).Trim();
        e.NewValues["JobType"]     = Helper.Safe.SafeString(e.NewValues["JobType"]).Trim();
        e.NewValues["StorageType"] = Helper.Safe.SafeString(e.NewValues["StorageType"]).Trim();
        e.NewValues["VehicleType"] = Helper.Safe.SafeString(e.NewValues["VehicleType"]).Trim();
        e.NewValues["GstType"]     = Helper.Safe.SafeString(e.NewValues["GstType"]).Trim();
        btn_search_Click(null, null);
    }
Exemplo n.º 21
0
    private void SaveJob()
    {
        try
        {
            ASPxPageControl            pageControl = this.grid_ref.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox                txtRefNo    = this.grid_ref.FindEditFormTemplateControl("txt_RefN") as ASPxTextBox;
            ASPxDateEdit               refDate     = this.grid_ref.FindEditFormTemplateControl("date_RefDate") as ASPxDateEdit;
            string                     refNo       = SafeValue.SafeString(txt_RefNo.Text, "");
            Wilson.ORMapper.OPathQuery query       = new Wilson.ORMapper.OPathQuery(typeof(AirImportRef), "RefNo='" + refNo + "'");
            AirImportRef               airRef      = C2.Manager.ORManager.GetObject(query) as AirImportRef;
            bool   isNew  = false;
            string userId = HttpContext.Current.User.Identity.Name;
            if (airRef == null)
            {
                airRef = new AirImportRef();
                isNew  = true;
                refNo  = C2Setup.GetNextNo("AE", "AirExport", refDate.Date);
                AirImport air = new AirImport();
                air.JobNo          = C2Setup.GetSubNo(refNo, "AE");
                air.CloseInd       = "N";
                air.CreateBy       = userId;
                air.CreateDateTime = DateTime.Now;
                air.RefNo          = refNo;
                air.Total          = "0";
                air.RefType        = "AE";
                air.StatusCode     = "USE";
                C2.Manager.ORManager.StartTracking(air, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(air);
            }
            ASPxButtonEdit txt_AgentId = this.grid_ref.FindEditFormTemplateControl("txt_AgentId") as ASPxButtonEdit;
            airRef.AgentId = txt_AgentId.Text;
            ASPxButtonEdit localCust = this.grid_ref.FindEditFormTemplateControl("txt_LocalCust") as ASPxButtonEdit;
            airRef.LocalCust = localCust.Text;
            ASPxMemo remarks = pageControl.FindControl("txt_Remarks") as ASPxMemo;
            airRef.Remarks = remarks.Text;
            ASPxButtonEdit tbxAirportCode0 = pageControl.FindControl("tbxAirportCode0") as ASPxButtonEdit;
            airRef.AirportCode0 = tbxAirportCode0.Text;
            ASPxTextBox tbxAirportName0 = pageControl.FindControl("tbxAirportName0") as ASPxTextBox;
            airRef.AirportName0 = tbxAirportName0.Text;
            ASPxDateEdit date_FlightDate0 = pageControl.FindControl("date_FlightDate0") as ASPxDateEdit;
            airRef.FlightDate0 = date_FlightDate0.Date;
            ASPxTextBox tbxFlightTime0 = pageControl.FindControl("tbxFlightTime0") as ASPxTextBox;
            airRef.FlightTime0 = tbxFlightTime0.Text;


            airRef.RefDate = refDate.Date;
            ASPxButtonEdit tbxAirportCode1 = pageControl.FindControl("txt_AirportCode1") as ASPxButtonEdit;
            airRef.AirportCode1 = tbxAirportCode1.Text;
            ASPxTextBox tbxAirportName1 = pageControl.FindControl("txt_AirportName1") as ASPxTextBox;
            airRef.AirportName1 = tbxAirportName1.Text;
            ASPxDateEdit spin_FlightDate1 = pageControl.FindControl("spin_FlightDate1") as ASPxDateEdit;
            airRef.FlightDate1 = spin_FlightDate1.Date;
            ASPxTextBox txt_FlightTime1 = pageControl.FindControl("txt_FlightTime1") as ASPxTextBox;
            airRef.FlightTime1 = txt_FlightTime1.Text;



            ASPxTextBox tbxAirlineCode1 = pageControl.FindControl("tbxAirlineCode1") as ASPxTextBox;
            airRef.AirlineCode1 = tbxAirlineCode1.Text;
            ASPxTextBox tbxAirlineName1 = pageControl.FindControl("tbxAirlineName1") as ASPxTextBox;
            airRef.AirlineName1 = tbxAirlineName1.Text;
            ASPxTextBox tbxFlightNo1 = pageControl.FindControl("tbxFlightNo1") as ASPxTextBox;
            airRef.FlightNo1 = tbxFlightNo1.Text;
            ASPxDateEdit tbxAirFlightDate1 = pageControl.FindControl("tbxAirFlightDate1") as ASPxDateEdit;
            airRef.AirFlightDate1 = tbxAirFlightDate1.Date;
            ASPxTextBox tbxAirFlightTime1 = pageControl.FindControl("tbxAirFlightTime1") as ASPxTextBox;
            airRef.AirFlightTime1 = tbxAirFlightTime1.Text;
            ASPxButtonEdit tbxAirLinePortCode1 = pageControl.FindControl("tbxAirLinePortCode1") as ASPxButtonEdit;
            airRef.AirLinePortCode1 = tbxAirLinePortCode1.Text;
            ASPxTextBox tbxAirLinePortName1 = pageControl.FindControl("tbxAirLinePortName1") as ASPxTextBox;
            airRef.AirLinePortName1 = tbxAirLinePortName1.Text;


            ASPxTextBox tbxAirlineCode2 = pageControl.FindControl("tbxAirlineCode2") as ASPxTextBox;
            airRef.AirlineCode2 = tbxAirlineCode2.Text;
            ASPxTextBox tbxAirlineName2 = pageControl.FindControl("tbxAirlineName2") as ASPxTextBox;
            airRef.AirlineName2 = tbxAirlineName2.Text;
            ASPxTextBox tbxFlightNo2 = pageControl.FindControl("tbxFlightNo2") as ASPxTextBox;
            airRef.FlightNo2 = tbxFlightNo2.Text;
            ASPxDateEdit tbxFlightDate2 = pageControl.FindControl("tbxFlightDate2") as ASPxDateEdit;
            airRef.FlightDate2 = tbxFlightDate2.Date;
            ASPxTextBox tbxFlightTime2 = pageControl.FindControl("tbxFlightTime2") as ASPxTextBox;
            airRef.FlightTime2 = tbxFlightTime2.Text;
            ASPxButtonEdit tbxAirportCode2 = pageControl.FindControl("tbxAirportCode2") as ASPxButtonEdit;
            airRef.AirportCode2 = tbxAirportCode2.Text;
            ASPxTextBox AirportName2 = pageControl.FindControl("tbxAirportName2") as ASPxTextBox;
            airRef.AirportName2 = AirportName2.Text;

            ASPxTextBox tbxAirlineCode3 = pageControl.FindControl("tbxAirlineCode3") as ASPxTextBox;
            airRef.AirlineCode3 = tbxAirlineCode3.Text;
            ASPxTextBox tbxAirlineName3 = pageControl.FindControl("tbxAirlineName3") as ASPxTextBox;
            airRef.AirlineName3 = tbxAirlineName3.Text;
            ASPxTextBox tbxFlightNo3 = pageControl.FindControl("tbxFlightNo3") as ASPxTextBox;
            airRef.FlightNo3 = tbxFlightNo3.Text;
            ASPxDateEdit tbxFlightDate3 = pageControl.FindControl("tbxFlightDate3") as ASPxDateEdit;
            airRef.FlightDate3 = tbxFlightDate3.Date;
            ASPxTextBox tbxFlightTime3 = pageControl.FindControl("tbxFlightTime3") as ASPxTextBox;
            airRef.FlightTime3 = tbxFlightTime3.Text;
            ASPxButtonEdit tbxAirportCode3 = pageControl.FindControl("tbxAirportCode3") as ASPxButtonEdit;
            airRef.AirportCode3 = tbxAirportCode3.Text;
            ASPxTextBox tbxAirportName3 = pageControl.FindControl("tbxAirportName3") as ASPxTextBox;
            airRef.AirportName3 = tbxAirportName3.Text;

            ASPxTextBox tbxAirlineCode4 = pageControl.FindControl("tbxAirlineCode4") as ASPxTextBox;
            airRef.AirlineCode4 = tbxAirlineCode4.Text;
            ASPxTextBox tbxAirlineName4 = pageControl.FindControl("tbxAirlineName4") as ASPxTextBox;
            airRef.AirlineName4 = tbxAirlineName4.Text;
            ASPxTextBox tbxFlightNo4 = pageControl.FindControl("tbxFlightNo4") as ASPxTextBox;
            airRef.FlightNo4 = tbxFlightNo4.Text;
            ASPxDateEdit tbxFlightDate4 = pageControl.FindControl("tbxFlightDate4") as ASPxDateEdit;
            airRef.FlightDate4 = tbxFlightDate4.Date;
            ASPxTextBox tbxFlightTime4 = pageControl.FindControl("tbxFlightTime4") as ASPxTextBox;
            airRef.FlightTime4 = tbxFlightTime4.Text;
            ASPxButtonEdit tbxAirportCode4 = pageControl.FindControl("tbxAirportCode4") as ASPxButtonEdit;
            airRef.AirportCode4 = tbxAirportCode4.Text;
            ASPxTextBox AirportName4 = pageControl.FindControl("tbxAirportName4") as ASPxTextBox;
            airRef.AirportName4 = AirportName4.Text;

            ASPxTextBox txtMAWB = this.grid_ref.FindEditFormTemplateControl("txt_MAWB") as ASPxTextBox;
            airRef.Mawb = txtMAWB.Text;

            ASPxButtonEdit txt_CrAgentId = this.grid_ref.FindEditFormTemplateControl("txt_CrAgentId") as ASPxButtonEdit;
            airRef.CarrierAgentId = txt_CrAgentId.Text;
            ASPxTextBox txt_CrBkgRefN = this.grid_ref.FindEditFormTemplateControl("txt_CrBkgRefN") as ASPxTextBox;
            airRef.CarrierBkgNo = txt_CrBkgRefN.Text;
            ASPxButtonEdit txt_NvoccAgentId = pageControl.FindControl("txt_NvoccAgentId") as ASPxButtonEdit;
            airRef.NvoccAgentId = txt_NvoccAgentId.Text;
            ASPxTextBox txt_NvoccBl = pageControl.FindControl("txt_NvoccBl") as ASPxTextBox;
            airRef.NvoccBlNO = txt_NvoccBl.Text;
            ASPxButtonEdit cbx_Currency = pageControl.FindControl("cbx_Currency") as ASPxButtonEdit;
            airRef.CurrencyId = cbx_Currency.Text;
            ASPxSpinEdit spin_CrExRate = pageControl.FindControl("spin_CrExRate") as ASPxSpinEdit;
            airRef.ExRate = SafeValue.SafeDecimal(spin_CrExRate.Value, 0);
            ASPxButtonEdit txt_WhId = pageControl.FindControl("txt_WhId") as ASPxButtonEdit;
            airRef.WareHouseId = txt_WhId.Text;
            ASPxMemo tbxShipperName = pageControl.FindControl("tbxShipperName") as ASPxMemo;
            airRef.ShipperName = tbxShipperName.Text;
            ASPxMemo tbxIssuedBy = pageControl.FindControl("tbxIssuedBy") as ASPxMemo;
            airRef.IssuedBy = tbxIssuedBy.Text;
            ASPxMemo tbxConsigneeName = pageControl.FindControl("tbxConsigneeName") as ASPxMemo;
            airRef.ConsigneeName = tbxConsigneeName.Text;
            ASPxMemo tbxCarrierAgent = pageControl.FindControl("tbxCarrierAgent") as ASPxMemo;
            airRef.CarrierAgent = tbxCarrierAgent.Text;
            ASPxMemo tbxAccountInfo = pageControl.FindControl("tbxAccountInfo") as ASPxMemo;
            airRef.AccountInfo = tbxAccountInfo.Text;
            ASPxTextBox tbxAgentIATACode = pageControl.FindControl("tbxAgentIATACode") as ASPxTextBox;
            airRef.AgentIATACode = tbxAgentIATACode.Text;
            ASPxTextBox tbxAgentAccountNo = pageControl.FindControl("tbxAgentAccountNo") as ASPxTextBox;
            airRef.AgentAccountNo = tbxAgentAccountNo.Text;
            ASPxTextBox tbxAirportDeparture = pageControl.FindControl("tbxAirportDeparture") as ASPxTextBox;
            airRef.AirportDeparture = tbxAirportDeparture.Text;
            ASPxTextBox tbxConnDest1 = pageControl.FindControl("tbxConnDest1") as ASPxTextBox;
            airRef.ConnDest1 = tbxConnDest1.Text;
            ASPxTextBox tbxConnCarrier1 = pageControl.FindControl("tbxConnCarrier1") as ASPxTextBox;
            airRef.ConnCarrier1 = tbxConnCarrier1.Text;
            ASPxTextBox tbxConnDest2 = pageControl.FindControl("tbxConnDest2") as ASPxTextBox;
            airRef.ConnDest2 = tbxConnDest2.Text;
            ASPxTextBox tbxConnCarrier2 = pageControl.FindControl("tbxConnCarrier2") as ASPxTextBox;
            airRef.ConnCarrier2 = tbxConnCarrier2.Text;
            ASPxTextBox tbxConnDest3 = pageControl.FindControl("tbxConnDest3") as ASPxTextBox;
            airRef.ConnDest3 = tbxConnDest3.Text;
            ASPxTextBox tbxConnCarrier3 = pageControl.FindControl("tbxConnCarrier3") as ASPxTextBox;
            airRef.ConnCarrier3 = tbxConnCarrier3.Text;
            ASPxTextBox tbxCurrency = pageControl.FindControl("tbxCurrency") as ASPxTextBox;
            airRef.Currency = tbxCurrency.Text;
            ASPxTextBox tbxChgsCode = pageControl.FindControl("tbxChgsCode") as ASPxTextBox;
            airRef.ChgsCode = tbxChgsCode.Text;
            ASPxTextBox tbxPPD1 = pageControl.FindControl("tbxPPD1") as ASPxTextBox;
            airRef.Ppd1 = tbxPPD1.Text;
            ASPxTextBox tbxCOLL1 = pageControl.FindControl("tbxCOLL1") as ASPxTextBox;
            airRef.Coll1 = tbxCOLL1.Text;
            ASPxTextBox tbxPPD2 = pageControl.FindControl("tbxPPD2") as ASPxTextBox;
            airRef.Ppd2 = tbxPPD2.Text;
            ASPxTextBox tbxCOLL2 = pageControl.FindControl("tbxCOLL2") as ASPxTextBox;
            airRef.Coll2 = tbxCOLL2.Text;
            ASPxTextBox tbxCarriageValue = pageControl.FindControl("tbxCarriageValue") as ASPxTextBox;
            airRef.CarriageValue = tbxCarriageValue.Text;
            ASPxTextBox tbxCustomValue = pageControl.FindControl("tbxCustomValue") as ASPxTextBox;
            airRef.CustomValue = tbxCustomValue.Text;
            ASPxTextBox tbxAirportDestination = pageControl.FindControl("tbxAirportDestination") as ASPxTextBox;
            airRef.AirportDestination = tbxAirportDestination.Text;
            ASPxTextBox tbxRequestedFlight = pageControl.FindControl("tbxRequestedFlight") as ASPxTextBox;
            airRef.RequestedFlight = tbxRequestedFlight.Text;
            ASPxTextBox tbxRequestedDate = pageControl.FindControl("tbxRequestedDate") as ASPxTextBox;
            airRef.RequestedDate = tbxRequestedDate.Text;
            ASPxTextBox tbxAmountInsurance = pageControl.FindControl("tbxAmountInsurance") as ASPxTextBox;
            airRef.AmountInsurance = tbxAmountInsurance.Text;
            ASPxMemo tbxHandlingInfo = pageControl.FindControl("tbxHandlingInfo") as ASPxMemo;
            airRef.HandlingInfo = tbxHandlingInfo.Text;
            ASPxTextBox tbxPiece = pageControl.FindControl("tbxPiece") as ASPxTextBox;
            airRef.Piece = tbxPiece.Text;
            ASPxSpinEdit tbxGrossWeight = pageControl.FindControl("tbxGrossWeight") as ASPxSpinEdit;
            airRef.GrossWeight = tbxGrossWeight.Text;
            ASPxSpinEdit tbxUnit = pageControl.FindControl("tbxUnit") as ASPxSpinEdit;
            airRef.Unit = tbxUnit.Text;
            ASPxTextBox tbxRateClass = pageControl.FindControl("tbxRateClass") as ASPxTextBox;
            airRef.RateClass = tbxRateClass.Text;
            ASPxTextBox tbxCommodityItemNo = pageControl.FindControl("tbxCommodityItemNo") as ASPxTextBox;
            airRef.CommodityItemNo = tbxCommodityItemNo.Text;
            ASPxSpinEdit tbxChargeableWeight = pageControl.FindControl("tbxChargeableWeight") as ASPxSpinEdit;
            airRef.ChargeableWeight = tbxChargeableWeight.Text;
            ASPxTextBox tbxRateCharge = pageControl.FindControl("tbxRateCharge") as ASPxTextBox;
            airRef.RateCharge = tbxRateCharge.Text;
            ASPxSpinEdit tbxTotal = pageControl.FindControl("tbxTotal") as ASPxSpinEdit;
            airRef.Total = tbxTotal.Text;
            ASPxMemo tbxGoodsNature = pageControl.FindControl("tbxGoodsNature") as ASPxMemo;
            airRef.GoodsNature = tbxGoodsNature.Text;
            ASPxMemo tbxContentRemark = pageControl.FindControl("tbxContentRemark") as ASPxMemo;
            airRef.ContentRemark = tbxContentRemark.Text;
            ASPxTextBox tbxWeightChargeP = pageControl.FindControl("tbxWeightChargeP") as ASPxTextBox;
            airRef.WeightChargeP = tbxWeightChargeP.Text;
            ASPxTextBox tbxWeightChargeC = pageControl.FindControl("tbxWeightChargeC") as ASPxTextBox;
            airRef.WeightChargeC = tbxWeightChargeC.Text;
            ASPxTextBox tbxValuationChargeP = pageControl.FindControl("tbxValuationChargeP") as ASPxTextBox;
            airRef.ValuationChargeP = tbxValuationChargeP.Text;
            ASPxTextBox tbxValuationChargeC = pageControl.FindControl("tbxValuationChargeC") as ASPxTextBox;
            airRef.ValuationChargeC = tbxValuationChargeC.Text;
            ASPxTextBox tbxTaxP = pageControl.FindControl("tbxTaxP") as ASPxTextBox;
            airRef.TaxP = tbxTaxP.Text;
            ASPxTextBox tbxTaxC = pageControl.FindControl("tbxTaxC") as ASPxTextBox;
            airRef.TaxC = tbxTaxC.Text;
            ASPxTextBox tbxOtherAgentChargeP = pageControl.FindControl("tbxOtherAgentChargeP") as ASPxTextBox;
            airRef.OtherAgentChargeP = tbxOtherAgentChargeP.Text;
            ASPxTextBox tbxOtherAgentChargeC = pageControl.FindControl("tbxOtherAgentChargeC") as ASPxTextBox;
            airRef.OtherAgentChargeC = tbxOtherAgentChargeC.Text;
            ASPxTextBox tbxOtherCarrierChargeP = pageControl.FindControl("tbxOtherCarrierChargeP") as ASPxTextBox;
            airRef.OtherCarrierChargeP = tbxOtherCarrierChargeP.Text;
            ASPxTextBox tbxOtherCarrierChargeC = pageControl.FindControl("tbxOtherCarrierChargeC") as ASPxTextBox;
            airRef.OtherCarrierChargeC = tbxOtherCarrierChargeC.Text;
            ASPxTextBox tbxTotalPrepaid = pageControl.FindControl("tbxTotalPrepaid") as ASPxTextBox;
            airRef.TotalPrepaid = tbxTotalPrepaid.Text;
            ASPxTextBox tbxTotalCollect = pageControl.FindControl("tbxTotalCollect") as ASPxTextBox;
            airRef.TotalCollect = tbxTotalCollect.Text;
            ASPxTextBox tbxCurrencyRate = pageControl.FindControl("tbxCurrencyRate") as ASPxTextBox;
            airRef.CurrencyRate = tbxCurrencyRate.Text;
            ASPxTextBox tbxChargeDestCurrency = pageControl.FindControl("tbxChargeDestCurrency") as ASPxTextBox;
            airRef.ChargeDestCurrency = tbxChargeDestCurrency.Text;

            ASPxTextBox tbxOtherCharge1 = pageControl.FindControl("tbxOtherCharge1") as ASPxTextBox;
            airRef.OtherCharge1 = tbxOtherCharge1.Text;
            ASPxTextBox tbxOtherCharge1Currency = pageControl.FindControl("tbxOtherCharge1Currency") as ASPxTextBox;
            airRef.OtherCharge1Currency = tbxOtherCharge1Currency.Text;
            ASPxSpinEdit tbxOtherCharge1Amount = pageControl.FindControl("tbxOtherCharge1Amount") as ASPxSpinEdit;
            airRef.OtherCharge1Amount = SafeValue.SafeDecimal(tbxOtherCharge1Amount.Text);

            ASPxTextBox tbxOtherCharge2 = pageControl.FindControl("tbxOtherCharge2") as ASPxTextBox;
            airRef.OtherCharge2 = tbxOtherCharge2.Text;
            ASPxTextBox tbxOtherCharge2Currency = pageControl.FindControl("tbxOtherCharge2Currency") as ASPxTextBox;
            airRef.OtherCharge2Currency = tbxOtherCharge2Currency.Text;
            ASPxSpinEdit tbxOtherCharge2Amount = pageControl.FindControl("tbxOtherCharge2Amount") as ASPxSpinEdit;
            airRef.OtherCharge2Amount = SafeValue.SafeDecimal(tbxOtherCharge2Amount.Text);

            ASPxTextBox tbxOtherCharge3 = pageControl.FindControl("tbxOtherCharge3") as ASPxTextBox;
            airRef.OtherCharge3 = tbxOtherCharge3.Text;
            ASPxTextBox tbxOtherCharge3Currency = pageControl.FindControl("tbxOtherCharge3Currency") as ASPxTextBox;
            airRef.OtherCharge3Currency = tbxOtherCharge3Currency.Text;
            ASPxSpinEdit tbxOtherCharge3Amount = pageControl.FindControl("tbxOtherCharge3Amount") as ASPxSpinEdit;
            airRef.OtherCharge3Amount = SafeValue.SafeDecimal(tbxOtherCharge3Amount.Text);

            ASPxTextBox tbxOtherCharge4 = pageControl.FindControl("tbxOtherCharge4") as ASPxTextBox;
            airRef.OtherCharge4 = tbxOtherCharge4.Text;
            ASPxTextBox tbxOtherCharge4Currency = pageControl.FindControl("tbxOtherCharge4Currency") as ASPxTextBox;
            airRef.OtherCharge4Currency = tbxOtherCharge4Currency.Text;
            ASPxSpinEdit tbxOtherCharge4Amount = pageControl.FindControl("tbxOtherCharge4Amount") as ASPxSpinEdit;
            airRef.OtherCharge4Amount = SafeValue.SafeDecimal(tbxOtherCharge4Amount.Text);

            ASPxTextBox tbxOtherCharge5 = pageControl.FindControl("tbxOtherCharge5") as ASPxTextBox;
            airRef.OtherCharge5 = tbxOtherCharge5.Text;
            ASPxTextBox tbxOtherCharge5Currency = pageControl.FindControl("tbxOtherCharge5Currency") as ASPxTextBox;
            airRef.OtherCharge5Currency = tbxOtherCharge5Currency.Text;
            ASPxSpinEdit tbxOtherCharge5Amount = pageControl.FindControl("tbxOtherCharge5Amount") as ASPxSpinEdit;
            airRef.OtherCharge5Amount = SafeValue.SafeDecimal(tbxOtherCharge5Amount.Text);

            ASPxTextBox tbxSignatureShipper = pageControl.FindControl("tbxSignatureShipper") as ASPxTextBox;
            airRef.SignatureShipper = tbxSignatureShipper.Text;
            ASPxTextBox tbxExecuteDate = pageControl.FindControl("tbxExecuteDate") as ASPxTextBox;
            airRef.ExecuteDate = tbxExecuteDate.Text;
            ASPxTextBox tbxExecutePlace = pageControl.FindControl("tbxExecutePlace") as ASPxTextBox;
            airRef.ExecutePlace = tbxExecutePlace.Text;
            ASPxTextBox tbxSignatureIssuing = pageControl.FindControl("tbxSignatureIssuing") as ASPxTextBox;
            airRef.SignatureIssuing = tbxSignatureIssuing.Text;
            if (isNew)
            {
                airRef.CloseInd       = "N";
                airRef.CreateBy       = userId;
                airRef.CreateDateTime = DateTime.Now;
                airRef.RefNo          = refNo.ToString();
                airRef.RefType        = "AE";
                airRef.UpdateBy       = userId;
                airRef.UpdateDateTime = DateTime.Now;
                airRef.StatusCode     = "USE";
                Manager.ORManager.StartTracking(airRef, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(airRef);
                C2Setup.SetNextNo(airRef.RefType, "AirExport", refNo, airRef.RefDate);
            }
            else
            {
                airRef.UpdateBy       = userId;
                airRef.UpdateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(airRef, Wilson.ORMapper.InitialState.Updated);
                Manager.ORManager.PersistChanges(airRef);
            }
            Session["AirExpMastWhere"]        = "RefNo='" + refNo + "'";
            this.dsImportRef.FilterExpression = Session["AirExpMastWhere"].ToString();
            if (this.grid_ref.GetRow(0) != null)
            {
                this.grid_ref.StartEdit(0);
            }
        }
        catch { }
    }
Exemplo n.º 22
0
 public string Get_Type()
 {
     return(SafeValue.SafeString(Request.QueryString["type"]));
 }
Exemplo n.º 23
0
    protected void grd_Photo_BeforePerformDataSelect(object sender, EventArgs e)
    {
        ASPxTextBox txtRefNo = this.grid_ref.FindEditFormTemplateControl("txt_RefN") as ASPxTextBox;

        this.dsJobPhoto.FilterExpression = "RefNo='" + SafeValue.SafeString(txtRefNo.Text, "") + "'";
    }
    protected void ASPxGridView1_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string doNo    = SafeValue.SafeString(Request.QueryString["Sn"].ToString());
        string whId    = SafeValue.SafeString(Request.QueryString["WhId"].ToString());
        string partyId = SafeValue.SafeString(Request.QueryString["partyId"].ToString());
        string s       = e.Parameters;

        if (s == "Save")
        {
            #region Create PO
            string sql = string.Format(@"select Count(*) from Wh_TransDet where DoNo='{0}'", doNo);
            int    cnt = SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0);
            if (cnt > 0)
            {
                bool action = false;
                for (int i = 0; i < list.Count; i++)
                {
                    int totalQty = list[i].pickQty;
                    int qty      = list[i].qty;
                    if (totalQty < qty)
                    {
                        action   = false;
                        e.Result = "Fail! Pls enter again";
                        return;
                    }
                    else
                    {
                        action = true;
                    }
                }
                if (action)
                {
                    string pId = "";
                    Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(WhTrans), "Id='" + pId + "'");
                    WhTrans whTrans = C2.Manager.ORManager.GetObject(query) as WhTrans;

                    whTrans = new WhTrans();
                    string poNo = C2Setup.GetNextNo("", "PurchaseOrders", DateTime.Now);
                    whTrans.DoNo           = poNo;
                    whTrans.DoType         = "PO";
                    whTrans.PartyId        = partyId;
                    whTrans.PartyName      = SafeValue.SafeString(partyId);
                    whTrans.CreateBy       = EzshipHelper.GetUserName();
                    whTrans.CreateDateTime = DateTime.Now;
                    whTrans.DoDate         = DateTime.Now;
                    whTrans.ExpectedDate   = DateTime.Today.AddDays(14);
                    whTrans.Currency       = "SGD";
                    whTrans.DoStatus       = "Draft";
                    whTrans.ExRate         = SafeValue.SafeDecimal(1.000000);
                    whTrans.WareHouseId    = whId;
                    Manager.ORManager.StartTracking(whTrans, Wilson.ORMapper.InitialState.Inserted);
                    Manager.ORManager.PersistChanges(whTrans);
                    C2Setup.SetNextNo("", "PurchaseOrders", poNo, DateTime.Now);


                    for (int i = 0; i < list.Count; i++)
                    {
                        string sku = list[i].sku;
                        //string lotNo = list[i].lotNo;
                        int     qty   = list[i].qty;
                        decimal price = list[i].price;
                        // string location = list[i].loc;
                        sql  = @"Insert Into Wh_TransDet(DoNo,ProductCode,DoType,Qty1,Price,LotNo,Uom1,Uom2,Uom3,Uom4,[QtyPackWhole],[QtyWholeLoose],[QtyLooseBase],[CreateBy],[CreateDateTime],[UpdateBy],[UpdateDateTime],Att1,Att2,Att3,Att4,Att5,Att6,Des1,Packing,LocationCode)";
                        sql += string.Format(@"select '{0}'as DoNo, '{1}' as Sku,'PO','{2}' as Qty1,'{3}','{5}',p.UomPacking,p.UomWhole,p.UomLoose,p.UomBase,p.QtyPackingWhole,p.QtyWholeLoose,p.QtyLooseBase,'{4}' as CreateBy,getdate() as CreateDateTime,
'{4}' as UpdateBy,getdate() as UpdateDateTime
,P.att4,P.att5,P.att6,P.att7,P.att8,P.att9,p.Description,p.Att1,'{6}'
from (select '{1}' as Sku) as tab
left join ref_product p on tab.Sku=p.Code", poNo, sku, qty, price, EzshipHelper.GetUserName(), "", "");
                        ConnectSql.ExecuteSql(sql);
                    }
                    e.Result = "Success! " + "Purchase Order No is" + whTrans.DoNo;
                }
            }
            else
            {
                e.Result = "Fail";
            }
            #endregion
        }
    }
Exemplo n.º 25
0
 protected void gv_Det_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
 {
     e.NewValues["Username"] = SafeValue.SafeString(e.NewValues["Username"]);
 }
Exemplo n.º 26
0
    public void Crane_ChangeStatus(string info)
    {
        JObject job = (JObject)JsonConvert.DeserializeObject(HttpUtility.UrlDecode(Server.UrlDecode(info)));
        List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();

        ConnectSql_mb.cmdParameters cpar = null;
        string status     = "1";
        string context    = Common.StringToJson("");
        string sql1       = "";
        string sql        = "";
        string Statuscode = job["Statuscode"].ToString();
        string ByUser     = job["ByUser"].ToString();

        if (Statuscode.Equals("S"))
        {
            sql  = string.Format(@"select DoubleMounting,DriverCode from CTM_JobDet2 where Id=@Id");
            list = new List <ConnectSql_mb.cmdParameters>();
            cpar = new ConnectSql_mb.cmdParameters("@Id", job["Id"], SqlDbType.Int);
            list.Add(cpar);
            DataTable dt         = ConnectSql_mb.GetDataTable(sql, list);
            string    dbMounting = "";
            string    DriverCode = "";
            if (dt.Rows.Count > 0)
            {
                dbMounting = SafeValue.SafeString(dt.Rows[0]["DoubleMounting"], "");
                DriverCode = SafeValue.SafeString(dt.Rows[0]["DriverCode"], "");
            }
            sql  = string.Format(@"select Id,DoubleMounting 
from ctm_jobdet2
where Statuscode='S' and DriverCode=@DriverCode");
            list = new List <ConnectSql_mb.cmdParameters>();
            list.Add(new ConnectSql_mb.cmdParameters("@DriverCode", DriverCode, SqlDbType.NVarChar, 100));
            dt = ConnectSql_mb.GetDataTable(sql, list);

            if (dt.Rows.Count > 0)
            {
                status  = "0";
                context = Common.StringToJson("Please end the other trip, then start this!");
            }
        }
        //if (Statuscode.Equals("C"))
        //{
        //    sql = string.Format(@"select isnull(sum(isnull(Qty,1)*isnull(Price,0)),0) as s from job_cost where TripNo=@Id and LineType='DP'");
        //    list = new List<ConnectSql_mb.cmdParameters>();
        //    cpar = new ConnectSql_mb.cmdParameters("@Id", job["Id"], SqlDbType.Int);
        //    list.Add(cpar);
        //    if (SafeValue.SafeDecimal(ConnectSql_mb.ExecuteScalar(sql, list).context, 0) == 0)
        //    {
        //        status = "0";
        //        context = Common.StringToJson("Require Trip Incentive!");
        //    }
        //}

        if (status.Equals("1"))
        {
            if (Statuscode.Equals("S"))
            {
                sql1 = ",FromDate=@FromDate,FromTime=@FromTime";
            }
            //if (Statuscode.Equals("C"))
            //{
            //    sql1 = ",ToDate=@ToDate,ToTime=@ToTime";
            //}
            if (Statuscode.Equals("C"))
            {
                sql1 = ",ToDate=@ToDate,ToTime=@ToTime,FromDate=BookingDate,FromTime=BookingTime";
            }

            DateTime dtime = DateTime.Now;
            string   time  = dtime.ToString("HH:mm");
            sql  = string.Format(@"update CTM_JobDet2 set Statuscode=@Statuscode{0} where Id=@Id", sql1);
            list = new List <ConnectSql_mb.cmdParameters>();
            cpar = new ConnectSql_mb.cmdParameters("@Id", job["Id"], SqlDbType.Int);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@Statuscode", Statuscode, SqlDbType.NVarChar, 100);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@FromDate", dtime, SqlDbType.DateTime);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@FromTime", time, SqlDbType.NVarChar, 10);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@ToDate", dtime, SqlDbType.DateTime);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@ToTime", time, SqlDbType.NVarChar, 10);
            list.Add(cpar);
            cpar = new ConnectSql_mb.cmdParameters("@ByUser", ByUser, SqlDbType.NVarChar, 20);
            list.Add(cpar);
            if (ConnectSql_mb.ExecuteNonQuery(sql, list).status)
            {
                status = "1";
                //EGL_JobTrip_AfterEndTrip(SafeValue.SafeString(job["Id"], "0"));


                //===========log
                C2.CtmJobEventLog lg = new C2.CtmJobEventLog();
                lg.Platform_isMobile();
                lg.Controller = SafeValue.SafeString(job["user"]);
                lg.Lat        = SafeValue.SafeString(job["Lat"]);
                lg.Lng        = SafeValue.SafeString(job["Lng"]);
                //lg.ActionLevel_isTRIP(SafeValue.SafeInt(job["Id"], 0));
                //lg.Remark = "Trip change status:" + Statuscode;
                lg.setActionLevel(SafeValue.SafeInt(job["Id"], 0), CtmJobEventLogRemark.Level.Trip, 4, ":" + Statuscode);
                lg.log();
            }
            else
            {
                status = "0";
            }
        }
        Common.WriteJsonP(status, context);
    }
Exemplo n.º 27
0
 protected void gv_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
 {
     e.NewValues["GroupName"] = SafeValue.SafeString(e.NewValues["GroupName"]);
     e.NewValues["Note1"]     = SafeValue.SafeString(e.NewValues["Note1"]);
 }
Exemplo n.º 28
0
    public void Attachment_Add(string info)
    {
        JObject job = (JObject)JsonConvert.DeserializeObject(HttpUtility.UrlDecode(Server.UrlDecode(info)));

        List <ConnectSql_mb.cmdParameters> list = new List <ConnectSql_mb.cmdParameters>();

        ConnectSql_mb.cmdParameters cpar = null;
        string status  = "0";
        string context = Common.StringToJson("");

        string sql = string.Format(@"insert into CTM_Attachment (JobType,RefNo,ContainerNo,TripId,FileType,FileName,FilePath,CreateBy,CreateDateTime,FileNote) values 
(@JobType,@RefNo,@ContainerNo,@TripId,@FileType,@FileName,@FilePath,@CreateBy,Getdate(),@FileNote)
select @@Identity");

        string fileStart = System.Configuration.ConfigurationManager.AppSettings["MobileServerUrl"].ToString();

        if (fileStart == null)
        {
            fileStart = "";
        }
        string fileEnd = job["FilePath"].ToString();

        fileEnd = fileEnd.Substring(0, fileEnd.LastIndexOf('/')) + "/500/" + fileEnd.Substring(fileEnd.LastIndexOf('/') + 1);
        fileEnd = fileStart + fileEnd;

        cpar = new ConnectSql_mb.cmdParameters("@JobType", "CTM", SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@RefNo", job["JobNo"], SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ContainerNo", job["ContainerNo"], SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@TripId", job["TripId"], SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@FileType", job["FileType"], SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@FileName", job["FileName"], SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@FilePath", fileEnd, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@CreateBy", job["CreateBy"], SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@FileNote", job["FileNote"], SqlDbType.NVarChar, 100);
        list.Add(cpar);
        ConnectSql_mb.sqlResult result = ConnectSql_mb.ExecuteScalar(sql, list);
        if (result.status)
        {
            status = "1";

            //===========log
            C2.CtmJobEventLog lg = new C2.CtmJobEventLog();
            lg.Platform_isMobile();
            lg.Controller = SafeValue.SafeString(job["user"]);
            lg.Lat        = SafeValue.SafeString(job["Lat"]);
            lg.Lng        = SafeValue.SafeString(job["Lng"]);
            //lg.fixActionInfo_ByAttachmentId(SafeValue.SafeInt(result.context, 0));
            //lg.Remark = "Attachment upload file:" + job["FileName"];
            lg.setActionLevel(SafeValue.SafeInt(result.context, 0), CtmJobEventLogRemark.Level.Attachment, 1, ":" + job["FileType"] + "[" + job["FileName"] + "]");
            lg.log();
        }

        Common.WriteJsonP(status, context);
    }
Exemplo n.º 29
0
 protected void grid_SKULine_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
 {
     e.Values["Id"] = SafeValue.SafeString(e.Values["Id"]);
 }
Exemplo n.º 30
0
    private void InsertInv_Det(int docId, string docNo, int index, string sku, string lotNo, string des, int qty, decimal price, string cur, decimal exRate, decimal gst, string soNo, string doNo, string mastType, string docType)
    {
        try
        {
            C2.XAArInvoiceDet det = new C2.XAArInvoiceDet();
            det.DocId     = docId;
            det.DocLineNo = index;
            det.DocNo     = docNo;
            det.DocType   = docType;
            det.AcCode    = SafeValue.SafeString(ConnectSql.ExecuteScalar(string.Format("select ArCode from ref_product where Code='{0}'", sku)), System.Configuration.ConfigurationManager.AppSettings["ItemArCode"]);
            det.AcSource  = "CR";
            det.MastRefNo = soNo;
            det.JobRefNo  = lotNo;
            if (doNo.Length > 0)
            {
                det.MastRefNo = doNo;
                det.JobRefNo  = "";
            }
            det.MastType  = mastType;
            det.SplitType = "";



            det.ChgCode = sku;
            det.ChgDes1 = des;
            det.ChgDes2 = "";
            det.ChgDes3 = "";

            det.Price    = price;
            det.Qty      = qty;
            det.Unit     = "";
            det.Currency = cur;
            det.ExRate   = 1;
            det.Gst      = gst;
            if (det.ExRate == 0)
            {
                det.ExRate = 1;
            }
            if (det.Gst > 0)
            {
                det.GstType = "S";
            }
            else if (det.Currency == System.Configuration.ConfigurationManager.AppSettings["Currency"])
            {
                det.GstType = "E";
            }
            else
            {
                det.GstType = "Z";
            }
            decimal amt    = SafeValue.ChinaRound(det.Qty * det.Price, 2);
            decimal gstAmt = SafeValue.ChinaRound((amt * det.Gst), 2);
            decimal docAmt = amt + gstAmt;
            decimal locAmt = SafeValue.ChinaRound(docAmt * det.ExRate, 2);
            det.GstAmt   = gstAmt;
            det.DocAmt   = docAmt;
            det.LocAmt   = locAmt;
            det.OtherAmt = 0;
            C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
            C2.Manager.ORManager.PersistChanges(det);
        }
        catch
        {
        }
    }