Ejemplo n.º 1
0
    public string CreateSO(string id)
    {
        string userId = HttpContext.Current.User.Identity.Name;
        string doNo   = "";

        doNo = C2Setup.GetNextNo("", "SaleOrders", DateTime.Now);
        string sql = string.Format(@"insert into Wh_Trans (DoNo,DoDate,PartyId,PartyName,Pic,PartyAdd,Currency,DoType,DoStatus,ExRate,SalesId,CreateBy,CreateDateTime,UpdateBy,UpdateDateTime
,AgentId,AgentName,AgentAdd,AgentContact,NotifyId,NotifyName)
select top 1 '{1}',GETDATE(),wh.PartyId,PartyName,PartyContact,PartyAdd,'SGD','SO','Draft',1,SalesId,'{2}',GETDATE(),'{2}',GETDATE()
,DoctorId,doc.Name,doc.Address,doc.Contact,Patient,pat.Name
from Wh_Schedule as wh
left outer join Ref_PersonInfo as doc on wh.DoctorId=doc.PartyId and doc.Type='Doctor'
left outer join Ref_PersonInfo as pat on wh.Patient=pat.ICNo and pat.Type='Patient'
where wh.Id='{0}'", id, doNo, userId);

        SafeValue.SafeInt(ConnectSql.ExecuteSql(sql), 0);
        C2Setup.SetNextNo("", "SaleOrders", doNo, DateTime.Now);

        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(WhSchedule), "Id='" + id + "'");
        WhSchedule s = C2.Manager.ORManager.GetObject(query) as WhSchedule;

        s.DoNo = doNo;
        Manager.ORManager.StartTracking(s, Wilson.ORMapper.InitialState.Updated);
        Manager.ORManager.PersistChanges(s);

        return(doNo);
    }
Ejemplo n.º 2
0
    protected void grid_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        e.NewValues["DocOwner"]  = "CLM";
        e.NewValues["DoType"]    = "IN3";
        e.NewValues["DocStatus"] = "Pending";
        e.NewValues["DocDate"]   = SafeValue.SafeDate(e.NewValues["DocDate"], DateTime.Now);
        if (S.Text(e.NewValues["DoType"]) == "OUT3")
        {
            string refNo = C2Setup.GetNextNo("", "CLM", S.Date(e.NewValues["DocDate"])); //SafeValue.SafeString(e.NewValues["RefNo"]);
            e.NewValues["BillNo"] = refNo;
            e.NewValues["DocNo"]  = refNo;
            C2Setup.SetNextNo("", "CLM", refNo, S.Date(e.NewValues["DocDate"]));
        }
        else
        {
            e.NewValues["BillNo"] = S.Text(e.NewValues["BillNo"]);
            e.NewValues["DocNo"]  = S.Text(e.NewValues["DocNo"]);
        }


        int qty = S.Int(e.NewValues["TotalNew"]);

        e.NewValues["TotalNew"]  = qty;
        e.NewValues["TotalUsed"] = 0;
        //e.NewValues["Qty"] = 0;
        //e.NewValues["Price"] = 0;
        //e.NewValues["GstAmt"] = 0;
        //e.NewValues["DocAmt"] = 0;
    }
Ejemplo n.º 3
0
    protected void grid_bkg_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        ASPxPageControl pageControl = this.grid_ref.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
        ASPxTextBox     refNo       = pageControl.FindControl("txt_RefN") as ASPxTextBox;

        e.NewValues["JobNo"] = C2Setup.GetSubNo(refNo.Text, "SE");
        e.NewValues["RefNo"] = refNo.Text;

        e.NewValues["CreateBy"]       = EzshipHelper.GetUserName();
        e.NewValues["CreateDateTime"] = DateTime.Now;
        e.NewValues["UpdateBy"]       = EzshipHelper.GetUserName();
        e.NewValues["UpdateDateTime"] = DateTime.Now;
        e.NewValues["StatusCode"]     = "USE";

        string sql_pod = string.Format("select Pod from SeaExportRef where RefNo='{0}'", refNo.Text);
        string pod1    = SafeValue.SafeString(Manager.ORManager.ExecuteScalar(sql_pod), "SGSIN");
        string expN    = C2Setup.GetNextNo("ExportBooking");
        string bkgN    = SafeValue.SafeString(System.Configuration.ConfigurationManager.AppSettings["BookingPrefix"]);

        //if (pol.Length == 5)
        //    bkgN += pol.Substring(2);
        if (pod1.Length == 5)
        {
            bkgN += pod1.Substring(2);
        }
        e.NewValues["BkgRefNo"] = bkgN + expN;

        string bkgN1 = SafeValue.SafeString(System.Configuration.ConfigurationManager.AppSettings["BookingPrefix"]);

        if (pod1.Length == 5)
        {
            bkgN1 += "/" + pod1.Substring(2);
        }
        e.NewValues["HblNo"] = bkgN1 + "/" + expN;
    }
Ejemplo n.º 4
0
    protected void grid_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        e.NewValues["DocOwner"]  = "CLM";
        e.NewValues["DoType"]    = "IN3";
        e.NewValues["DocStatus"] = "Pending";
        e.NewValues["DocDate"]   = SafeValue.SafeDate(e.NewValues["DocDate"], DateTime.Now);
        if (S.Text(e.NewValues["DoType"]) == "OUT3")
        {
            string refNo = C2Setup.GetNextNo("", "CLM", S.Date(e.NewValues["DocDate"])); //SafeValue.SafeString(e.NewValues["RefNo"]);
            e.NewValues["BillNo"] = refNo;
            e.NewValues["DocNo"]  = refNo;
            C2Setup.SetNextNo("", "CLM", refNo, S.Date(e.NewValues["DocDate"]));
        }
        else
        {
            e.NewValues["BillNo"] = S.Text(e.NewValues["BillNo"]);
            e.NewValues["DocNo"]  = S.Text(e.NewValues["DocNo"]);
        }

        string  gst    = S.Text(e.NewValues["GstType"]);
        decimal qty    = S.Decimal(e.NewValues["Qty"]);
        decimal price  = S.Decimal(e.NewValues["Price"]);
        decimal tot    = SafeValue.ChinaRound(qty * price, 2);
        decimal gstamt = 0;

        if (gst == "S")
        {
            gstamt = SafeValue.ChinaRound(tot * S.Decimal(0.07), 2);
        }
        tot += gstamt;
        e.NewValues["Qty"]    = qty;
        e.NewValues["Price"]  = price;
        e.NewValues["GstAmt"] = gstamt;
        e.NewValues["DocAmt"] = tot;
    }
Ejemplo n.º 5
0
 private void Save()
 {
     try
     {
         ASPxPageControl            pageControl = this.grid.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
         ASPxTextBox                txtId       = pageControl.FindControl("txt_Id") as ASPxTextBox;
         string                     id          = SafeValue.SafeString(txtId.Text, "");
         Wilson.ORMapper.OPathQuery query       = new Wilson.ORMapper.OPathQuery(typeof(WhContract), "Id='" + id + "'");
         WhContract                 contract    = C2.Manager.ORManager.GetObject(query) as WhContract;
         bool   isNew      = false;
         string contractNo = "";
         if (contract == null)
         {
             contract   = new WhContract();
             isNew      = true;
             contractNo = C2Setup.GetNextNo("Contract");
         }
         ASPxButtonEdit txt_PartyId = pageControl.FindControl("txt_PartyId") as ASPxButtonEdit;
         contract.PartyId = txt_PartyId.Text;
         ASPxDateEdit txt_Date = pageControl.FindControl("txt_Date") as ASPxDateEdit;
         contract.ContractDate = txt_Date.Date;
         ASPxDateEdit txt_StartDate = pageControl.FindControl("txt_StartDate") as ASPxDateEdit;
         contract.StartDate = txt_StartDate.Date;
         ASPxDateEdit txt_ExpireDate = pageControl.FindControl("txt_ExpireDate") as ASPxDateEdit;
         contract.ExpireDate = txt_ExpireDate.Date;
         ASPxButtonEdit txt_WarehouseId = pageControl.FindControl("txt_WarehouseId") as ASPxButtonEdit;
         contract.WhCode = txt_WarehouseId.Text;
         ASPxButtonEdit txt_SalesmanId = pageControl.FindControl("txt_SalesmanId") as ASPxButtonEdit;
         ASPxComboBox   cmb_Type       = pageControl.FindControl("cmb_Type") as ASPxComboBox;
         contract.StorageType = cmb_Type.Text;
         ASPxMemo txt_Remark = pageControl.FindControl("txt_Remark") as ASPxMemo;
         contract.Remark = txt_Remark.Text;
         string userId = HttpContext.Current.User.Identity.Name;
         if (isNew)
         {
             contract.CreateBy       = userId;
             contract.CreateDateTime = DateTime.Now;
             contract.ContractNo     = contractNo.ToString();
             contract.StatusCode     = "USE";
             Manager.ORManager.StartTracking(contract, Wilson.ORMapper.InitialState.Inserted);
             Manager.ORManager.PersistChanges(contract);
             C2Setup.SetNextNo("Contract", contractNo);
         }
         else
         {
             contract.UpdateBy       = userId;
             contract.UpdateDateTime = DateTime.Now;
             Manager.ORManager.StartTracking(contract, Wilson.ORMapper.InitialState.Updated);
             Manager.ORManager.PersistChanges(contract);
         }
         Session["ContractWhere"]           = "ContractNo='" + contract.ContractNo + "'";
         this.dsWhContract.FilterExpression = Session["ContractWhere"].ToString();
         if (this.grid.GetRow(0) != null)
         {
             this.grid.StartEdit(0);
         }
     }
     catch { }
 }
Ejemplo n.º 6
0
    protected void grid_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
    {
        string lotNo = C2Setup.GetNextNo("", "LOTNO", DateTime.Today);

        e.NewValues["Description"]    = "";
        e.NewValues["Code"]           = lotNo;
        e.NewValues["CreateBy"]       = EzshipHelper.GetUserName();
        e.NewValues["CreateDateTime"] = DateTime.Now;
    }
Ejemplo n.º 7
0
    private void Job_New_Save(DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        DateTime date  = DateTime.Now;
        string   time4 = date.ToString("HHmm");

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

        string jobType1 = jobType;

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

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

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

        #region invoice mast
        counterType = "AP-PAYMENT-Job";
        C2.XAApPayment inv = new C2.XAApPayment();


        inv.DocDate = docDate;
        string invN = C2Setup.GetNextNo("", counterType, inv.DocDate);
        inv.PartyTo  = "PSAC";
        inv.DocType  = "PS";
        inv.DocType1 = "Job";
        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.ChqNo    = "GIRO";
        //

        inv.Remark     = "";
        inv.CurrencyId = cur;
        inv.ExRate     = 1;
        inv.AcCode     = "120401";
        inv.AcSource   = "CR";
        inv.MastRefNo  = "";
        inv.JobRefNo   = "";

        inv.ExportInd      = "N";
        inv.CreateBy       = HttpContext.Current.User.Identity.Name;
        inv.CreateDateTime = 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);

            invId = inv.SequenceId;

            invN = C2Setup.GetNextNo("AP-PAYMENT-" + inv.DocType1);
            string sql = string.Format("Update XAApPayment set DocNo='{1}',GenerateInd='Y' where SequenceId='{0}'", invId, invN);
            if (ConnectSql.ExecuteSql(sql) > -1)
            {
                C2Setup.SetNextNo("AP-PAYMENT-" + inv.DocType1, invN);
            }
        }
        catch
        {
        }
        #endregion
        return(invId);
    }
    protected void grid_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string paras = e.Parameters;

        if (paras == "Assign")
        {
            ASPxSpinEdit spin_Qty         = grid.FindRowCellTemplateControl(0, null, "spin_Qty") as ASPxSpinEdit;
            ASPxSpinEdit spin_Weight      = grid.FindRowCellTemplateControl(0, null, "spin_Weight") as ASPxSpinEdit;
            ASPxSpinEdit spin_Volume      = grid.FindRowCellTemplateControl(0, null, "spin_Volume") as ASPxSpinEdit;
            ASPxDateEdit date_ShipDate    = grid.FindRowCellTemplateControl(0, null, "date_ShipDate") as ASPxDateEdit;
            ASPxComboBox cbb_ShipIndex    = grid.FindRowCellTemplateControl(0, null, "cbb_ShipIndex") as ASPxComboBox;
            ASPxTextBox  txt_ShipPortCode = grid.FindRowCellTemplateControl(0, null, "txt_ShipPortCode") as ASPxTextBox;
            ASPxComboBox cbb_ContIndex    = grid.FindRowCellTemplateControl(0, null, "cbb_ContIndex") as ASPxComboBox;

            DateTime now   = DateTime.Now;
            string   jobNo = "";
            string   refNo = "";
            Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(C2.JobHouse), "Id=" + lbl_Id.Text + "");
            C2.JobHouse house = C2.Manager.ORManager.GetObject(query) as C2.JobHouse;
            if (house != null)
            {
                #region
                refNo = house.JobNo;
                C2.CtmJob job = new CtmJob();
                jobNo          = C2Setup.GetNextNo("", "CTM_Job_WDO", DateTime.Now);
                job.JobNo      = jobNo;
                job.JobDate    = DateTime.Now;
                job.ClientId   = house.ConsigneeInfo;
                job.DeliveryTo = "";
                C2.Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(job);
                C2Setup.SetNextNo("", "CTM_Job_WDO", jobNo, now);

                house.LineId       = SafeValue.SafeInt(lbl_Id.Text, 0);
                job.JobType        = "WDO";
                house.JobNo        = jobNo;
                house.RefNo        = refNo;
                house.CargoType    = "OUT";
                house.CargoStatus  = "P";
                house.QtyOrig      = SafeValue.SafeDecimal(spin_Qty.Value);
                house.WeightOrig   = SafeValue.SafeDecimal(spin_Weight.Value);
                house.VolumeOrig   = SafeValue.SafeDecimal(spin_Volume.Value);
                house.ShipDate     = date_ShipDate.Date;
                house.ShipIndex    = SafeValue.SafeInt(cbb_ShipIndex.Value, 0);
                house.ShipPortCode = txt_ShipPortCode.Text;
                house.ContIndex    = SafeValue.SafeString(cbb_ContIndex.Value);
                C2.Manager.ORManager.StartTracking(house, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(house);

                #endregion
            }
            e.Result = "Action Success! No is " + jobNo;
        }
    }
Ejemplo n.º 10
0
    protected void ASPxGridView1_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string s = e.Parameters;

        if (s == "Save")
        {
            C2.bill_doc  inv           = new C2.bill_doc();
            ASPxComboBox txtCustomerId = ASPxPopupControl1.FindControl("cmb_Customer") as ASPxComboBox;
            ASPxDateEdit txtDocDt      = ASPxPopupControl1.FindControl("txt_DocDt") as ASPxDateEdit;
            ASPxComboBox txtTermId     = ASPxPopupControl1.FindControl("txt_TermId") as ASPxComboBox;

            string counterType = "AR-SIN";

            inv.DocType = "SIN";
            inv.DocDate = txtDocDt.Date;
            string invN = C2Setup.GetNextNo(inv.DocType, counterType, inv.DocDate);
            inv.DocNo   = invN;
            inv.PartyTo = SafeValue.SafeString(txtCustomerId.Value, "");
            string[] currentPeriod = EzshipHelper.GetAccPeriod(txtDocDt.Date);

            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], txtDocDt.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], txtDocDt.Date.Month);
            inv.Term     = txtTermId.Text;
            //
            int dueDay = SafeValue.SafeInt(txtTermId.Text.ToUpper().Replace("DAYS", "").Trim(), 0);
            inv.DocDueDate = inv.DocDate.AddDays(dueDay);//SafeValue.SafeDate(dueDt.Text, DateTime.Now);

            inv.AcCode   = EzshipHelper.GetAccArCode(inv.PartyTo, inv.CurrencyId);;
            inv.AcSource = "DB";

            inv.MastRefNo  = "0";
            inv.JobRefNo   = "0";
            inv.MastType   = "";
            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);
            }
            catch
            {
            }
            e.Result = invN;
            //ClientScriptManager cs = Page.ClientScript;
            //cs.RegisterStartupScript(this.GetType(), "", "<script type=\"text/javascript\">txt_Remark.SetText();cmb_PackType.SetText();spin_Pkgs.SetText();spin_Volume.SetText();spin_Weight.SetText();cmb_Carrier.SetText();cmb_Customer.SetText();cbx_jobCate.SetText();ASPxPopupClientControl.Hide();parent.navTab.openTab(\"" + order.JobNo + "\",\"/Z/job_edit.aspx?id=" + order.SequenceId + "\"" + ",{title:\"" + order.JobNo + "\", fresh:false, external:true});</script>");
        }
    }
Ejemplo n.º 11
0
    protected void AddOrUpdate()
    {
        ASPxPageControl pageControl = this.grid.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
        ASPxTextBox     txt_pId     = pageControl.FindControl("txt_Id") as ASPxTextBox;
        string          pId         = SafeValue.SafeString(txt_pId.Text, "");

        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(WhInventory), "Id='" + pId + "'");
        WhInventory obj         = C2.Manager.ORManager.GetObject(query) as WhInventory;
        bool        action      = false;
        string      inventoryNo = "";

        if (obj == null)
        {
            action      = true;
            obj         = new WhInventory();
            inventoryNo = C2Setup.GetNextNo("Inventory");
        }

        ASPxTextBox txt_InventoryNo = pageControl.FindControl("txt_InventoryNo") as ASPxTextBox;

        obj.InventoryNo = txt_InventoryNo.Text.Trim();
        ASPxDateEdit date_InventoryDate = pageControl.FindControl("date_InventoryDate") as ASPxDateEdit;

        obj.InventoryDate = date_InventoryDate.Date;

        ASPxTextBox txt_InventoryUser = pageControl.FindControl("txt_InventoryUser") as ASPxTextBox;

        obj.InventoryUser = txt_InventoryUser.Text;

        if (action)
        {
            obj.InventoryNo    = inventoryNo;
            obj.CreateBy       = HttpContext.Current.User.Identity.Name;
            obj.CreateDateTime = DateTime.Now;
            C2Setup.SetNextNo("Inventory", inventoryNo);
            Manager.ORManager.StartTracking(obj, Wilson.ORMapper.InitialState.Inserted);
            Manager.ORManager.PersistChanges(obj);
            Session["NameWhere"] = "InventoryNo='" + inventoryNo + "'";
            this.dsWhInventory.FilterExpression = Session["NameWhere"].ToString();
            if (this.grid.GetRow(0) != null)
            {
                this.grid.StartEdit(0);
            }
        }
        else
        {
            obj.UpdateBy       = HttpContext.Current.User.Identity.Name;
            obj.UpdateDateTime = DateTime.Now;
            Manager.ORManager.StartTracking(obj, Wilson.ORMapper.InitialState.Updated);
            Manager.ORManager.PersistChanges(obj);
        }
    }
Ejemplo n.º 12
0
    protected string SaveNewJob()
    {
        try
        {
            ASPxDateEdit issueDate = ASPxPopupControl1.FindControl("date_IssueDate") as ASPxDateEdit;
            string       issueN    = "";
            JobInfo      job       = new JobInfo();
            issueN      = C2Setup.GetNextNo("", "JobOrder", issueDate.Date);
            job.JobDate = issueDate.Date;

            job.JobStage = "Customer Inquir";
            ASPxComboBox cmb_JobType = ASPxPopupControl1.FindControl("cmb_JobType") as ASPxComboBox;
            job.JobType = SafeValue.SafeString(cmb_JobType.Value);
            //Main Info
            ASPxButtonEdit txt_CustomerId = ASPxPopupControl1.FindControl("txt_CustomerId") as ASPxButtonEdit;
            job.CustomerId = txt_CustomerId.Text;
            ASPxTextBox txt_CustomerName = ASPxPopupControl1.FindControl("txt_CustomerName") as ASPxTextBox;
            job.CustomerName = txt_CustomerName.Text;
            ASPxMemo memo_Address = ASPxPopupControl1.FindControl("memo_NewAddress") as ASPxMemo;
            job.CustomerAdd = memo_Address.Text;

            ASPxTextBox txt_PostalCode = ASPxPopupControl1.FindControl("txt_NewPostalCode") as ASPxTextBox;
            job.Postalcode = txt_PostalCode.Text;
            ASPxTextBox txt_Contact = ASPxPopupControl1.FindControl("txt_NewContact") as ASPxTextBox;
            job.Contact = txt_Contact.Text;
            ASPxTextBox txt_Tel = ASPxPopupControl1.FindControl("txt_NewTel") as ASPxTextBox;
            job.Tel = txt_Tel.Text;
            ASPxTextBox txt_Email = ASPxPopupControl1.FindControl("txt_NewEmail") as ASPxTextBox;
            job.Email = txt_Email.Text;
            ASPxTextBox txt_Fax = ASPxPopupControl1.FindControl("txt_NewFax") as ASPxTextBox;
            job.Fax = txt_Fax.Text;
            ASPxMemo remark = ASPxPopupControl1.FindControl("txt_NewRemark") as ASPxMemo;
            job.Remark     = remark.Text;
            job.WorkStatus = "PENDING";

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

            job.CreateBy       = userId;
            job.CreateDateTime = DateTime.Now;
            job.UpdateBy       = userId;
            job.UpdateDateTime = DateTime.Now;
            job.JobNo          = issueN;
            Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted);
            Manager.ORManager.PersistChanges(job);
            C2Setup.SetNextNo("", "JobOrder", issueN, issueDate.Date);

            return(job.JobNo);
        }
        catch { }
        return("");
    }
Ejemplo n.º 13
0
    protected void ASPxGridView1_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string s = e.Parameters;

        if (s == "Save")
        {
            C2.rate_doc  inv           = new C2.rate_doc();
            ASPxComboBox txtCustomerId = ASPxPopupControl1.FindControl("cmb_Customer") as ASPxComboBox;
            ASPxDateEdit txtDocDt      = ASPxPopupControl1.FindControl("txt_DocDt") as ASPxDateEdit;
            ASPxComboBox txtTermId     = ASPxPopupControl1.FindControl("txt_TermId") as ASPxComboBox;

            string counterType = "AR-SQU";

            inv.DocType = "SQU";
            inv.DocDate = txtDocDt.Date;
            string invN = C2Setup.GetNextNo(inv.DocType, counterType, inv.DocDate);
            inv.DocNo   = invN;
            inv.PartyTo = SafeValue.SafeString(txtCustomerId.Value, "");
            string[] currentPeriod = EzshipHelper.GetAccPeriod(txtDocDt.Date);

            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], txtDocDt.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], txtDocDt.Date.Month);
            inv.Term     = txtTermId.Text;
            //
            int dueDay = SafeValue.SafeInt(txtTermId.Text.ToUpper().Replace("DAYS", "").Trim(), 0);
            inv.DocDueDate = inv.DocDate.AddDays(dueDay);//SafeValue.SafeDate(dueDt.Text, DateTime.Now);

            inv.AcCode   = EzshipHelper.GetAccArCode(inv.PartyTo, inv.CurrencyId);;
            inv.AcSource = "DB";

            inv.MastRefNo  = "0";
            inv.JobRefNo   = "0";
            inv.MastType   = "";
            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);
            }
            catch
            {
            }
            e.Result = invN;
        }
    }
Ejemplo n.º 14
0
    private void Job_New_Save(DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        DateTime date  = DateTime.Now;
        string   time4 = date.ToString("HHmm");

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

        string jobType1 = jobType;

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

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

        if (i == 1)
        {
            if (jobStatus == "Quoted")
            {
                C2Setup.SetNextNo("", "CTM_Job_" + jobStatus, quoteNo, txt_new_JobDate.Date);
                //GetJobRate(quoteNo, btn_new_ClientId.Text, SafeValue.SafeString(cbb_new_jobtype.Value));
                e.Result = quoteNo;
            }
            else
            {
                C2Setup.SetNextNo("", "CTM_Job_" + jobType1, jobno, txt_new_JobDate.Date);
                e.Result = jobno;
            }
        }
    }
Ejemplo n.º 15
0
    protected void grid_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        e.NewValues["DocOwner"]  = "SPJ";
        e.NewValues["DoType"]    = "OUT3";
        e.NewValues["DocStatus"] = "Pending";
        e.NewValues["DocDate"]   = SafeValue.SafeDate(e.NewValues["DocDate"], DateTime.Now);
        if (S.Text(e.NewValues["DoType"]) == "OUT3")
        {
            if (S.Text(e.NewValues["BillNo"]).Length < 5)
            {
                string refNo = C2Setup.GetNextNo("", "SPJ", S.Date(e.NewValues["DocDate"]));                //SafeValue.SafeString(e.NewValues["RefNo"]);
                e.NewValues["BillNo"] = refNo;
                e.NewValues["DocNo"]  = refNo;
                C2Setup.SetNextNo("", "SPJ", refNo, S.Date(e.NewValues["DocDate"]));
            }
            else
            {
                e.NewValues["BillNo"] = S.Text(e.NewValues["BillNo"]);
                e.NewValues["DocNo"]  = S.Text(e.NewValues["DocNo"]);
            }
        }
        else
        {
            e.NewValues["BillNo"] = S.Text(e.NewValues["BillNo"]);
            e.NewValues["DocNo"]  = S.Text(e.NewValues["DocNo"]);
        }

        string  gst    = S.Text(e.NewValues["GstType"]);
        decimal qty    = S.Decimal(e.NewValues["Qty"]);
        string  party  = S.Text(e.NewValues["PartyTo"]);
        string  code   = S.Text(e.NewValues["Code"]);
        decimal price  = D.Dec("select top 1 price from Materials where DoType='RT3' and PartyTo='" + party + "' and Code='" + code + "'");
        decimal tot    = SafeValue.ChinaRound(qty * price, 2);
        decimal gstamt = 0;

        if (gst == "S")
        {
            gstamt = SafeValue.ChinaRound(tot * S.Decimal(0.07), 2);
        }
        tot += gstamt;
        e.NewValues["Qty"]    = qty;
        e.NewValues["Price"]  = price;
        e.NewValues["GstAmt"] = gstamt;
        e.NewValues["DocAmt"] = tot;
    }
Ejemplo n.º 16
0
    private string AddPurchase(DataTable tab, string doNo, string partyId, string partyName, string wh)
    {
        string poNo = "";
        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();
        poNo                   = C2Setup.GetNextNo("", "PurchaseOrders", DateTime.Now);
        whTrans.DoNo           = poNo;
        whTrans.DoType         = "PO";
        whTrans.PartyId        = partyId;
        whTrans.PartyName      = partyName;
        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    = wh;
        whTrans.BlanketNo      = txt_DoNo.Text;
        Manager.ORManager.StartTracking(whTrans, Wilson.ORMapper.InitialState.Inserted);
        Manager.ORManager.PersistChanges(whTrans);
        C2Setup.SetNextNo("", "PurchaseOrders", poNo, DateTime.Now);


        for (int i = 0; i < tab.Rows.Count; i++)
        {
            string  sku      = SafeValue.SafeString(tab.Rows[i]["ProductCode"]);
            string  lotNo    = SafeValue.SafeString(tab.Rows[i]["LotNo"]);
            int     qty      = SafeValue.SafeInt(tab.Rows[i]["Qty1"], 0);
            decimal price    = SafeValue.SafeDecimal(tab.Rows[i]["Price"]);
            string  location = SafeValue.SafeString(tab.Rows[i]["LocationCode"]);
            string  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, 0, price, EzshipHelper.GetUserName(), lotNo, location);
            ConnectSql.ExecuteSql(sql);
        }
        return(poNo);
    }
Ejemplo n.º 17
0
    private string add_job(string client)
    {
        DateTime now   = DateTime.Now;
        string   jobNo = "";

        C2.CtmJob job = new C2.CtmJob();
        jobNo           = C2Setup.GetNextNo("", "CTM_Job_WGR", DateTime.Now);
        job.JobNo       = jobNo;
        job.JobDate     = DateTime.Now;
        job.ClientId    = client;
        job.DeliveryTo  = "";
        job.StatusCode  = "USE";
        job.QuoteNo     = jobNo;
        job.QuoteStatus = "None";
        job.JobStatus   = "Confirmed";
        job.JobType     = "WGR";
        C2.Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted);
        C2.Manager.ORManager.PersistChanges(job);
        C2Setup.SetNextNo("", "CTM_Job_WGR", jobNo, now);
        return(jobNo);
    }
Ejemplo n.º 18
0
    protected void grid_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string s = e.Parameters;

        if (s == "Auto")
        {
            for (int i = 0; i < 10; i++)
            {
                WhLotNo lot   = new WhLotNo();
                string  lotNo = C2Setup.GetNextNo("", "LOTNO", DateTime.Today);
                lot.Code           = lotNo;
                lot.Description    = lotNo;
                lot.CreateBy       = EzshipHelper.GetUserName();
                lot.CreateDateTime = DateTime.Now;

                C2Setup.SetNextNo("", "LOTNO", lotNo, DateTime.Today);
                Manager.ORManager.StartTracking(lot, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(lot);
            }
            e.Result = "Success";
        }
    }
Ejemplo n.º 19
0
    private void Job_New_Save(DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        DateTime date      = DateTime.Now;
        string   time4     = date.ToString("HHmm");
        string   jobType   = SafeValue.SafeString(cbb_new_jobtype.Value, "CONSOL");
        string   jobStatus = SafeValue.SafeString(cbb_new_jobstatus.Text, "Quoted");
        //string jobType1 = "IMP";
        //if (jobType.IndexOf("EXP") > -1)
        //{
        //    jobType1 = "EXP";
        //}
        string jobType1 = jobType;

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

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

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

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

            elog.setActionLevel(jobId, CtmJobEventLogRemark.Level.Job, 1);
            elog.ActionLevel_isJOB(jobId);
            C2Setup.SetNextNo("I", "CI", jobno, date);
            e.Result = jobno;
            elog.log();
        }
    }
Ejemplo n.º 20
0
    private string create_job(DateTime now)
    {
        C2.CtmJob job   = new C2.CtmJob();
        string    jobNo = C2Setup.GetNextNo("", "CTM_Job_WDO", DateTime.Now);

        job.JobNo   = jobNo;
        job.JobDate = DateTime.Now;
        string client = System.Configuration.ConfigurationManager.AppSettings["EdiClient"];

        job.ClientId    = EzshipHelper.GetPartyId(client);
        job.DeliveryTo  = "";
        job.JobType     = "WDO";
        job.StatusCode  = "USE";
        job.Contractor  = "YES";
        job.HaulierId   = job.ClientId;
        job.QuoteNo     = jobNo;
        job.JobStatus   = "Confirmed";
        job.QuoteStatus = "None";
        job.QuoteDate   = DateTime.Today;
        C2.Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted);
        C2.Manager.ORManager.PersistChanges(job);
        C2Setup.SetNextNo("", "CTM_Job_WDO", jobNo, now);
        return(jobNo);
    }
Ejemplo n.º 21
0
    protected void grid_SKULine_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string s      = e.Parameters;
        string soNo   = SafeValue.SafeString(Request.QueryString["no"].ToString());
        string schId  = SafeValue.SafeString(Request.QueryString["SchId"].ToString());
        string userId = HttpContext.Current.User.Identity.Name;

        if (s == "Save")
        {
            bool      result = false;
            string    issueN = "";
            string    sql    = string.Format(@"select * from Wh_TransDet where DoNo='{0}'", soNo);
            DataTable tab    = ConnectSql.GetTab(sql);
            for (int i = 0; i < tab.Rows.Count; i++)
            {
                if (SafeValue.SafeInt(tab.Rows[i]["Qty1"], 0) == 0)
                {
                    e.Result = "Fail,Please keyin Qty ";
                    return;
                }
            }
            C2.XAArInvoice inv    = null;
            C2.XAArInvoice inv_Do = null;
            if (tab.Rows.Count > 0)
            {
                //Get SO
                #region Get So
                bool isNew = false;
                Wilson.ORMapper.OPathQuery query1 = new Wilson.ORMapper.OPathQuery(typeof(WhTrans), "DoNo='" + soNo + "'");
                WhTrans   so     = C2.Manager.ORManager.GetObject(query1) as WhTrans;
                string    sql1   = string.Format("select doNo from wh_do where DoType='Out' and PoNo='{0}'", soNo);
                DataTable tab_do = ConnectSql.GetTab(sql1);
                string where = "(1=0";
                for (int i = 0; i < tab_do.Rows.Count; i++)
                {
                    where += string.Format(" or DoNo='{0}' ", tab_do.Rows[i][0]);
                }
                where += ")";

                int cnt = 0;
                sql = string.Format("select count(*) from wh_transDet where DoNo='{0}' and DoType='SO' and isnull(LotNo,'')='' ", soNo);
                cnt = SafeValue.SafeInt(ConnectSql.ExecuteSql(sql), 0);
                if (cnt > 0)
                {
                    e.Result = "No Balance Qty or No Lot No!";
                    return;
                }
                string update = string.Format(@"update Wh_Schedule set StatusCode='Closed' where Id='{1}'", soNo, schId);
                C2.Manager.ORManager.ExecuteCommand(update);
                #endregion
                #region Create SO Invoice
                int    invId = 0;
                string invN  = "";
                inv = Manager.ORManager.GetObject(typeof(XAArInvoice), SafeValue.SafeInt(invId, 0)) as XAArInvoice;
                if (inv == null)// first insert invoice
                {
                    string counterType = "AR-IV";
                    inv         = new XAArInvoice();
                    invN        = C2Setup.GetNextNo("", counterType, so.DoDate);
                    inv.PartyTo = SafeValue.SafeString(so.PartyId, "");
                    inv.DocType = "IV";
                    inv.DocNo   = invN.ToString();
                    inv.DocDate = so.DoDate;
                    string[] currentPeriod = EzshipHelper.GetAccPeriod(so.DoDate);

                    inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], so.DoDate.Year);
                    inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], so.DoDate.Month);
                    inv.Term     = so.PayTerm;

                    //
                    int dueDay = 0;
                    if (so.PayTerm != null)
                    {
                        dueDay = SafeValue.SafeInt(so.PayTerm.ToUpper().Replace("DAYS", ""), 0);
                    }

                    inv.DocDueDate  = inv.DocDate.AddDays(dueDay);//SafeValue.SafeDate(dueDt.Text, DateTime.Now);
                    inv.Description = so.Remark;
                    inv.CurrencyId  = so.Currency;
                    inv.ExRate      = SafeValue.SafeDecimal(so.ExRate, 1);
                    if (inv.ExRate <= 0)
                    {
                        inv.ExRate = 1;
                    }
                    inv.AcCode      = EzshipHelper.GetAccArCode(inv.PartyTo, inv.CurrencyId);
                    inv.AcSource    = "DB";
                    inv.SpecialNote = "";

                    inv.MastType  = "WH";
                    inv.MastRefNo = so.DoNo;
                    inv.JobRefNo  = "";

                    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);
                    }
                    catch
                    {
                    }
                }
                #endregion
                #region Create DO
                //Create DoNo
                string doId = "";
                Wilson.ORMapper.OPathQuery query2 = new Wilson.ORMapper.OPathQuery(typeof(WhDo), "Id='" + doId + "'");
                WhDo whDo = C2.Manager.ORManager.GetObject(query2) as WhDo;

                if (whDo == null)
                {
                    whDo        = new WhDo();
                    isNew       = true;
                    issueN      = C2Setup.GetNextNo("", "DOOUT", so.DoDate);
                    whDo.DoType = "OUT";
                }
                whDo.DoNo           = issueN;
                whDo.PoNo           = so.DoNo;
                whDo.DoDate         = so.DoDate;
                whDo.PoDate         = so.DoDate;
                whDo.StatusCode     = "CLS";
                whDo.PartyId        = so.PartyId;
                whDo.PartyName      = so.PartyName;
                whDo.AgentId        = so.AgentId;
                whDo.AgentName      = so.AgentName;
                whDo.AgentTel       = so.AgentTel;
                whDo.AgentZip       = so.AgentZip;
                whDo.AgentCountry   = so.AgentCountry;
                whDo.AgentCity      = so.AgentCity;
                whDo.NotifyId       = so.NotifyId;
                whDo.NotifyName     = so.NotifyName;
                whDo.WareHouseId    = so.WareHouseId;
                whDo.CreateBy       = so.CreateBy;
                whDo.CreateDateTime = so.CreateDateTime;
                whDo.UpdateBy       = so.UpdateBy;
                whDo.UpdateDateTime = so.UpdateDateTime;
                if (isNew)
                {
                    Manager.ORManager.StartTracking(whDo, Wilson.ORMapper.InitialState.Inserted);
                    Manager.ORManager.PersistChanges(whDo);
                    C2Setup.SetNextNo("", "DOOUT", issueN, DateTime.Now);
                }
                #endregion
                #region Create DO Invoice
                inv_Do = Manager.ORManager.GetObject(typeof(XAArInvoice), SafeValue.SafeInt(invId, 0)) as XAArInvoice;
                if (inv_Do == null)// first insert invoice
                {
                    string counterType = "AR-IV";
                    inv_Do         = new XAArInvoice();
                    invN           = C2Setup.GetNextNo("", counterType, so.DoDate);
                    inv_Do.PartyTo = SafeValue.SafeString(so.PartyId, "");
                    inv_Do.DocType = "IV";
                    inv_Do.DocNo   = invN.ToString();
                    inv_Do.DocDate = so.DoDate;
                    string[] currentPeriod = EzshipHelper.GetAccPeriod(so.DoDate);

                    inv_Do.AcYear   = SafeValue.SafeInt(currentPeriod[1], so.DoDate.Year);
                    inv_Do.AcPeriod = SafeValue.SafeInt(currentPeriod[0], so.DoDate.Month);
                    inv_Do.Term     = so.PayTerm;

                    //
                    int dueDay = 0;
                    if (so.PayTerm != null)
                    {
                        dueDay = SafeValue.SafeInt(so.PayTerm.ToUpper().Replace("DAYS", ""), 0);
                    }

                    inv_Do.DocDueDate  = inv.DocDate.AddDays(dueDay);//SafeValue.SafeDate(dueDt.Text, DateTime.Now);
                    inv_Do.Description = so.Remark;
                    inv_Do.CurrencyId  = so.Currency;
                    inv_Do.ExRate      = SafeValue.SafeDecimal(so.ExRate, 1);
                    if (inv_Do.ExRate <= 0)
                    {
                        inv_Do.ExRate = 1;
                    }
                    inv_Do.AcCode      = EzshipHelper.GetAccArCode(inv.PartyTo, inv.CurrencyId);
                    inv_Do.AcSource    = "DB";
                    inv_Do.SpecialNote = "";

                    inv_Do.MastType  = "WH";
                    inv_Do.MastRefNo = whDo.DoNo;
                    inv_Do.JobRefNo  = "";

                    inv_Do.ExportInd  = "N";
                    inv_Do.UserId     = HttpContext.Current.User.Identity.Name;
                    inv_Do.EntryDate  = DateTime.Now;
                    inv_Do.CancelDate = new DateTime(1900, 1, 1);
                    inv_Do.CancelInd  = "N";
                    try
                    {
                        C2.Manager.ORManager.StartTracking(inv_Do, Wilson.ORMapper.InitialState.Inserted);
                        C2.Manager.ORManager.PersistChanges(inv_Do);
                        C2Setup.SetNextNo("", counterType, invN, inv_Do.DocDate);
                    }
                    catch
                    {
                    }
                }
                #endregion
            }
            #region Create Transfer
            for (int i = 0; i < tab.Rows.Count; i++)
            {
                string  product  = SafeValue.SafeString(tab.Rows[i]["ProductCode"]);
                string  lotNo    = SafeValue.SafeString(tab.Rows[i]["LotNo"]);
                int     qty      = SafeValue.SafeInt(tab.Rows[i]["Qty1"], 0);
                decimal price    = SafeValue.SafeDecimal(tab.Rows[i]["Price"]);
                string  des1     = SafeValue.SafeString(tab.Rows[i]["Des1"]);
                string  location = SafeValue.SafeString(tab.Rows[i]["LocationCode"]);

                sql  = @"Insert Into wh_DoDet(JobStatus,DoNo, DoType,ProductCode,ExpiredDate,Price,Qty1,Qty2,Qty3,Qty4,Qty5,LotNo,BatchNo,CustomsLot,Uom1,Uom2,Uom3,Uom4,[QtyPackWhole],[QtyWholeLoose],[QtyLooseBase],Att1,Att2,Att3,Att4,Att5,Att6,Att7,Att8,Att9,Att10,Des1,Packing,[CreateBy],[CreateDateTime],[UpdateBy],[UpdateDateTime],DoInId)";
                sql += string.Format(@" select * from (select 'Picked' as JobStatus,'{1}'as DoNo, 'Out' as DoType,ProductCode,ExpiredDate,Price
,Qty1 as Qty1
,0 as Qty2
,0 as Qty3
,Qty1 as Qty4
,0 as Qty5
, LotNo,BatchNo,CustomsLot,Uom1,Uom2,Uom3,Uom4,[QtyPackWhole],[QtyWholeLoose],[QtyLooseBase],Att1,Att2,Att3,Att4,Att5,Att6,Att7,Att8,Att9,Att10,Des1,Packing,'{2}' as CreateBy,getdate() as CreateDateTime,'{2}' as UpdateBy,getdate() as UpdateDateTime,Id as DoInId from Wh_TransDet where DoNo='{0}' and ProductCode='{4}' and LotNo='{5}' and DoType='SO' and LocationCode='{3}'
 ) as tab_aa where qty4>0  ", soNo, issueN, userId, location, product, lotNo);

                C2.Manager.ORManager.ExecuteCommand(sql);

                sql  = @"Insert Into Wh_DoDet2(DoNo,DoType,Product,Qty1,Qty2,Qty3,Price,LotNo,Uom1,Uom2,Uom3,Uom4,[QtyPackWhole],[QtyWholeLoose],[QtyLooseBase],[CreateBy],[CreateDateTime],[UpdateBy],[UpdateDateTime],Att1,Att2,Att3,Att4,Att5,Att6,Des1,Packing,Location,ProcessStatus)";
                sql += string.Format(@"select '{0}'as DoNo, 'OUT' as DoType,'{1}' as Sku
 ,'{2}' as Qty1
 ,0 as Qty2
 ,0 as Qty3
 ,'{3}' as Price
,'{4}' as LotNo
,ref.UomPacking as Uom1,ref.UomWhole as Uom2,ref.UomLoose as Uom3,ref.UomBase as Uom4
,ref.QtyPackingWhole as QtyPackWhole,ref.QtyWholeLoose as  QtyWholeLoose,ref.QtyLooseBase as QtyLooseBase
,'{5}' as CreateBy,getdate() as CreateDateTime,'{5}' as UpdateBy,getdate() as UpdateDateTime
,ref.Att4 as Att1,ref.Att5 as Att2,ref.att6 as Att3,ref.att7 as Att4,ref.att8 as Att5,ref.att9 as Att6,ref.Description as Des1,'' as Packing,'{6}' as Location,'Delivered' as ProcessStatus
from (select '{1}' as Sku) as tab inner join ref_product ref on ref.Code=tab.Sku", issueN, product, qty, price, lotNo, userId, location);
                C2.Manager.ORManager.ExecuteCommand(sql);
                InsertInv_Det(inv.SequenceId, inv.DocNo, i + 1, product, lotNo, des1, qty, price, inv.CurrencyId, inv.ExRate, 0, inv.MastRefNo, "", inv.MastType, "IV");
                UpdateMaster(inv.SequenceId);

                InsertInv_Det(inv_Do.SequenceId, inv_Do.DocNo, i + 1, product, lotNo, des1, qty, price, inv_Do.CurrencyId, inv_Do.ExRate, 0, inv_Do.MastRefNo, "", inv_Do.MastType, "IV");
                UpdateMaster(inv_Do.SequenceId);
                if (soNo.Length > 0)
                {
                    result = true;
                }
            }
            #endregion
            if (result)
            {
                e.Result = issueN;
            }
            else
            {
                e.Result = "Fail,Please keyin select product ";
            }
        }
    }
Ejemplo n.º 22
0
    private void Save()
    {
        try
        {
            ASPxPageControl            pageControl = this.grid.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox                txtId       = pageControl.FindControl("txt_Id") as ASPxTextBox;
            string                     id          = SafeValue.SafeString(txtId.Text, "");
            Wilson.ORMapper.OPathQuery query       = new Wilson.ORMapper.OPathQuery(typeof(WhSo), "Id='" + id + "'");
            WhSo   whSo  = C2.Manager.ORManager.GetObject(query) as WhSo;
            bool   isNew = false;
            string soNo  = "";
            if (whSo == null)
            {
                whSo       = new WhSo();
                isNew      = true;
                soNo       = C2Setup.GetNextNo("SaleOrders");
                txtId.Text = SafeValue.SafeString(whSo.Id);
            }
            ASPxTextBox txt_PartyRefNo = pageControl.FindControl("txt_PartyRefNo") as ASPxTextBox;
            whSo.PartyRefNo = txt_PartyRefNo.Text;
            ASPxButtonEdit txt_PartyId = pageControl.FindControl("txt_PartyId") as ASPxButtonEdit;
            whSo.PartyId = txt_PartyId.Text;
            ASPxDateEdit txt_SoDate = pageControl.FindControl("txt_SoDate") as ASPxDateEdit;
            whSo.SoDate = txt_SoDate.Date;
            ASPxDateEdit txt_RequestDate = pageControl.FindControl("txt_RequestDate") as ASPxDateEdit;
            whSo.RequestDate = txt_RequestDate.Date;
            ASPxButtonEdit txt_SalesmanId = pageControl.FindControl("txt_SalesmanId") as ASPxButtonEdit;
            whSo.SalesmanId = txt_SalesmanId.Text;
            ASPxButtonEdit txt_WarehouseId = pageControl.FindControl("txt_WarehouseId") as ASPxButtonEdit;
            whSo.WarehouseId = txt_WarehouseId.Text;
            ASPxButtonEdit txt_Currency = pageControl.FindControl("txt_Currency") as ASPxButtonEdit;
            whSo.Currency = txt_Currency.Text;
            ASPxSpinEdit spin_ExRate = pageControl.FindControl("spin_ExRate") as ASPxSpinEdit;
            whSo.ExRate = SafeValue.SafeDecimal(spin_ExRate.Value, 1);
            ASPxMemo txt_Remark = pageControl.FindControl("txt_Remark") as ASPxMemo;
            whSo.Remark = txt_Remark.Text;

            ASPxSpinEdit txt_DocAmt = pageControl.FindControl("spin_DocAmt") as ASPxSpinEdit;
            whSo.DocAmt = SafeValue.SafeDecimal(txt_DocAmt.Value, 1);
            ASPxSpinEdit txt_LocAmt = pageControl.FindControl("spin_LocAmt") as ASPxSpinEdit;
            whSo.LocAmt = SafeValue.SafeDecimal(txt_DocAmt.Value, 1) * whSo.ExRate;

            string userId = HttpContext.Current.User.Identity.Name;
            if (isNew)
            {
                whSo.CreateBy       = userId;
                whSo.CreateDateTime = DateTime.Now;
                whSo.SoNo           = soNo.ToString();
                whSo.StatusCode     = "USE";
                Manager.ORManager.StartTracking(whSo, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(whSo);
                C2Setup.SetNextNo("SaleOrders", soNo);
            }
            else
            {
                whSo.UpdateBy       = userId;
                whSo.UpdateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(whSo, Wilson.ORMapper.InitialState.Updated);
                Manager.ORManager.PersistChanges(whSo);
            }
            Session["SOWhere"]           = "SoNo='" + whSo.SoNo + "'";
            this.dsWhSo.FilterExpression = Session["SOWhere"].ToString();
            if (this.grid.GetRow(0) != null)
            {
                this.grid.StartEdit(0);
            }
        }
        catch { }
    }
Ejemplo n.º 23
0
    protected void ASPxGridView1_CustomDataCallback(object sender, ASPxGridViewCustomDataCallbackEventArgs e)
    {
        string      filter = e.Parameters;
        ASPxTextBox oidCtr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;

        //ASPxTextBox docN = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;

        if (filter == "P")
        {
            SaveBill();
            #region Post
            string sql = @"SELECT AcYear, AcPeriod, DocType, DocNo, DocDate, DocCurrency, DocExRate, PartyTo, OtherPartyName, DocAmt, LocAmt, AcCode, AcSource, ChqNo, ChqDate, ExportInd, 
                      BankName, Remark,GenerateInd FROM  pay_doc";
            sql += " WHERE Id='" + oidCtr.Text + "'";
            DataTable dt             = Manager.ORManager.GetDataSet(sql).Tables[0];
            int       acYear         = 0;
            int       acPeriod       = 0;
            string    docN           = "";
            string    docType        = "";
            string    acSource       = "";
            string    acCode         = "";
            decimal   locAmt         = 0;
            decimal   docAmt         = 0;
            decimal   exRate         = 0;
            string    currency       = "";
            DateTime  docDt          = DateTime.Today;
            string    remarks        = "";
            string    partyTo        = "";
            string    otherPartyName = "";
            string    chqNo          = "";
            string    generateInd    = "";
            if (dt.Rows.Count == 1)
            {
                acYear   = SafeValue.SafeInt(dt.Rows[0]["AcYear"], 0);
                acPeriod = SafeValue.SafeInt(dt.Rows[0]["AcPeriod"], 0);
                acSource = dt.Rows[0]["AcSource"].ToString();
                acCode   = dt.Rows[0]["AcCode"].ToString();
                docN     = dt.Rows[0]["DocNo"].ToString();
                docType  = dt.Rows[0]["DocType"].ToString();
                locAmt   = SafeValue.SafeDecimal(dt.Rows[0]["LocAmt"].ToString(), 0);
                docAmt   = SafeValue.SafeDecimal(dt.Rows[0]["DocAmt"].ToString(), 0);
                exRate   = SafeValue.SafeDecimal(dt.Rows[0]["DocExRate"].ToString(), 0);
                currency = dt.Rows[0]["DocCurrency"].ToString();
                docDt    = SafeValue.SafeDate(dt.Rows[0]["DocDate"], new DateTime(1900, 1, 1));
                // partyId = dt.Rows[0][""].ToString();
                remarks        = dt.Rows[0]["Remark"].ToString();
                partyTo        = dt.Rows[0]["PartyTo"].ToString();
                otherPartyName = dt.Rows[0]["OtherPartyName"].ToString();
                chqNo          = dt.Rows[0]["ChqNo"].ToString();
                generateInd    = SafeValue.SafeString(dt.Rows[0]["GenerateInd"]);
            }
            else
            {
                e.Result = "Can't find the ArReceipt!";
                return;
            }
            if (generateInd.ToUpper() != "Y")
            {
                e.Result = "Have not generate no!";
                return;
            }

            string sqlDet = string.Format("select count(Id) from pay_line where RepId='{0}'", oidCtr.Text);
            int    detCnt = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sqlDet), 0);
            if (detCnt == 0)
            {
                e.Result = "No Detail, Can't Post";
                return;
            }
            sqlDet = string.Format("select max(docDate) from pay_line where RepId='{0}'", oidCtr.Text);
            DateTime maxLineDocDate = SafeValue.SafeDate(Manager.ORManager.ExecuteScalar(sqlDet), new DateTime(1900, 1, 1));
            if (maxLineDocDate > new DateTime(2000, 1, 1) && maxLineDocDate > docDt)
            {
                e.Result = "The bill's Date can't be greater than receipt date.";
                return;
            }

            //check account period
            if (acYear < 1 || acPeriod < 1)
            {
                e.Result = "Account year or Period Invalid!";
                return;
            }
            string sql1     = "select CloseInd from XXAccPeriod where Year='" + acYear + "' and Period ='" + acPeriod + "'";
            string closeInd = SafeValue.SafeString(Manager.ORManager.ExecuteScalar(sql1), "");
            if (closeInd == "")
            {
                e.Result = "Can't find this account period!";
                return;
            }
            else if (closeInd == "Y")
            {
                e.Result = "The account period is closed!";
                return;
            }
            //mast.amt det.amt is match
            sql = string.Format("select sum(locamt) from pay_line where RepId='{0}' and AcSource='CR'", oidCtr.Text);
            decimal amt_detCr = SafeValue.SafeDecimal(Manager.ORManager.ExecuteScalar(sql), 0);
            sql = string.Format("select sum(locamt) from pay_line where RepId='{0}' and AcSource='DB'", oidCtr.Text);
            decimal amt_detDb = SafeValue.SafeDecimal(Manager.ORManager.ExecuteScalar(sql), 0);
            if (docType == "RE" && locAmt != amt_detCr - amt_detDb)
            {
                e.Result = "Amount can't match, can't post";
                return;
            }
            else if (docType == "PC" && locAmt != -amt_detCr + amt_detDb)
            {
                e.Result = "Amount can't match, can't post";
                return;
            }

            sql    = "select count(*) from pay_line where AcCode='' and RepId='" + oidCtr.Text + "'";
            detCnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            if (detCnt > 0)
            {
                e.Result = "Some Item's Accode is blank, pls check";
                return;
            }
            //delete old post data
            sql = string.Format("SELECT SequenceId from XAGlEntry WHERE DocNo='{0}' and DocType='{1}'", docN, docType);
            int glOldOid = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql), 0);
            if (glOldOid > 0)
            {
                DeleteGl(glOldOid);
            }

            //Insert into gl entry
            int glOid = 0;
            try
            {
                C2.XAGlEntry gl = new XAGlEntry();
                gl.AcPeriod         = acPeriod;
                gl.AcYear           = acYear;
                gl.ArApInd          = "AR";
                gl.DocType          = docType;
                gl.DocDate          = docDt;
                gl.DocNo            = docN;
                gl.CrAmt            = docAmt;
                gl.DbAmt            = docAmt;
                gl.CurrencyCrAmt    = locAmt;
                gl.CurrencyDbAmt    = locAmt;
                gl.CurrencyId       = currency;
                gl.EntryDate        = DateTime.Now;
                gl.ExRate           = exRate;
                gl.PostDate         = DateTime.Now;
                gl.PostInd          = "N";
                gl.Remark           = remarks;
                gl.UserId           = HttpContext.Current.User.Identity.Name;
                gl.CancelInd        = "N";
                gl.CancelDate       = new DateTime(1900, 1, 1);
                gl.PartyTo          = partyTo;
                gl.OtherPartyName   = otherPartyName;
                gl.ChqNo            = chqNo;
                gl.SupplierBillNo   = "";
                gl.SupplierBillDate = new DateTime(1900, 1, 1);
                Manager.ORManager.StartTracking(gl, InitialState.Inserted);
                Manager.ORManager.PersistChanges(gl);
                glOid = gl.SequenceId;

                //insert Detail
                OPathQuery   query = new OPathQuery(typeof(pay_line), "RepId='" + oidCtr.Text + "'");
                ObjectSet    set   = Manager.ORManager.GetObjectSet(query);
                int          index = 1;
                XAGlEntryDet det1  = new XAGlEntryDet();

                det1.AcCode        = acCode;
                det1.ArApInd       = "AR";
                det1.AcPeriod      = acPeriod;
                det1.AcSource      = acSource;
                det1.AcYear        = acYear;
                det1.CrAmt         = 0;
                det1.CurrencyCrAmt = 0;
                det1.DbAmt         = docAmt;
                det1.CurrencyDbAmt = locAmt;
                det1.CurrencyId    = currency;
                det1.DocNo         = docN;
                det1.DocType       = docType;
                det1.ExRate        = exRate;
                det1.GlLineNo      = index;
                det1.GlNo          = gl.SequenceId;
                det1.Remark        = remarks;


                Manager.ORManager.StartTracking(det1, InitialState.Inserted);
                Manager.ORManager.PersistChanges(det1);
                for (int i = 0; i < set.Count; i++)
                {
                    try
                    {
                        index++;
                        pay_line     invDet = set[i] as pay_line;
                        XAGlEntryDet det    = new XAGlEntryDet();

                        det.AcCode   = invDet.AcCode;
                        det.ArApInd  = "AR";
                        det.AcPeriod = acPeriod;
                        det.AcSource = invDet.AcSource;
                        det.AcYear   = acYear;
                        if (invDet.AcSource == "DB")
                        {
                            det.DbAmt         = invDet.DocAmt;
                            det.CurrencyDbAmt = invDet.LocAmt;
                            det.CrAmt         = 0;
                            det.CurrencyCrAmt = 0;
                        }
                        else// if (det.AcSource == "CR")
                        {
                            det.CrAmt         = invDet.DocAmt;
                            det.CurrencyCrAmt = invDet.LocAmt;
                            det.DbAmt         = 0;
                            det.CurrencyDbAmt = 0;
                        }
                        det.CurrencyId = invDet.Currency;

                        det.DocNo    = docN;
                        det.DocType  = docType;
                        det.ExRate   = invDet.ExRate;
                        det.GlLineNo = index;
                        det.GlNo     = gl.SequenceId;
                        det.Remark   = invDet.Remark1;


                        Manager.ORManager.StartTracking(det, InitialState.Inserted);
                        Manager.ORManager.PersistChanges(det);
                    }
                    catch
                    {
                        e.Result = "Posting Error, Please repost!";
                        DeleteGl(glOid);
                    }
                }
                UpdateArInv(oidCtr.Text);
                EzshipLog.Log(docN, "", docType, "Post");
                e.Result = "Post completely!";
            }
            catch
            {
                e.Result = "Posting Error, Please repost!";
                DeleteGl(glOid);
            }
            #endregion
        }
        else if (filter == "DD")
        {
            #region delete receipt

            try
            {
                string    sql = "SELECT Id,DocId, DocType FROM pay_line where RepId ='" + oidCtr.Text + "'";
                DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
                for (int i = 0; i < tab.Rows.Count; i++)
                {
                    try
                    {
                        string id      = tab.Rows[i]["Id"].ToString();
                        string docId   = tab.Rows[i]["DocId"].ToString();
                        string docType = tab.Rows[i]["DocType"].ToString();
                        string sql_det = "delete from pay_line where Id='" + id + "'";
                        if (C2.Manager.ORManager.ExecuteCommand(sql_det) > 0)
                        {
                            UpdateMaster(docId, docType);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            #endregion
        }
        else if (filter == "Reverse")
        {
            #region reverse receipt 0:period is closed? 1:unpost 2:exportind='N' 3: delete all item

            try
            {
                string sql1 = string.Format("select CloseInd from xxaccperiod where Year=(select AcYear from pay_doc where Id='{0}') and Period=(select top(1)AcPeriod from pay_doc where SequenceId='{0}')", oidCtr.Text);
                if (SafeValue.SafeString(ConnectSql.ExecuteScalar(sql1)) != "N")
                {
                    throw new Exception("Acc Period is Closed!");
                }
                string sql_invoice = string.Format("select sequenceid from xaglentry where ArApInd='AR' and docno=(select docno from pay_doc where id='{0}') and DocType=(select doctype from pay_doc where id='{0}') ", oidCtr.Text);
                DeleteGl(SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql_invoice), 0));

                sql_invoice = "update pay_doc set IsReturn='true', ExportInd='N' where Id='" + oidCtr.Text + "'";
                Manager.ORManager.ExecuteCommand(sql_invoice);

                string    sql = "SELECT Id,DocId, DocType FROM pay_line where RepId ='" + oidCtr.Text + "'";
                DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
                for (int i = 0; i < tab.Rows.Count; i++)
                {
                    try
                    {
                        string id      = tab.Rows[i]["Id"].ToString();
                        string docId   = tab.Rows[i]["DocId"].ToString();
                        string docType = tab.Rows[i]["DocType"].ToString();
                        string sql_det = "delete from pay_line where Id='" + id + "'";
                        if (C2.Manager.ORManager.ExecuteCommand(sql_det) > 0)
                        {
                            UpdateMaster(docId, docType);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            #endregion
        }
        else if (filter == "GainLoss")
        {
            #region GAIN LOSS
            ASPxComboBox docType = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox;
            string       sql     = string.Format("select (select LocAmt from pay_doc where Id='{0}')-iSNULL(sum(case when AcSource='CR' then -LocAmt else LocAmt end),0) As LocAmt from pay_line where repid='{0}'", oidCtr.Text);
            if (docType.Text == "RE")
            {
                sql = string.Format("select (select LocAmt from pay_doc where Id='{0}')-iSNULL(sum(case when AcSource='DB' then -LocAmt else LocAmt end),0) As LocAmt from pay_line where repid='{0}'", oidCtr.Text);
            }
            decimal balAmt = SafeValue.SafeDecimal(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            if (balAmt > 0)
            {
                string   gainAccCode = System.Configuration.ConfigurationManager.AppSettings["GainLoseAcCode"];
                pay_line det         = new pay_line();
                det.AcCode = gainAccCode;
                if (docType.Text == "RE")
                {
                    det.AcSource = "CR";
                }
                else
                {
                    det.AcSource = "DB";
                }
                det.DocType  = docType.Text;
                det.RepType  = docType.Text;
                det.Currency = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                det.DocAmt   = balAmt;
                det.DocDate  = new DateTime(1900, 1, 1);
                det.DocId    = 0;
                det.DocNo    = "";
                det.ExRate   = 1;
                det.LocAmt   = balAmt;
                det.Remark1  = "GAIN AND LOSS";
                det.Remark2  = "";
                det.Remark3  = "";
                det.RepId    = SafeValue.SafeInt(oidCtr.Text, 0);
                ASPxTextBox docN = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
                det.RepNo = docN.Text;
                string sql_detCnt = "select count(DocNo) from pay_line where RepId='" + oidCtr.Text + "'";
                int    lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;
                det.RepLineNo = lineNo;
                C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(det);
            }
            else if (balAmt < 0)
            {
                string   gainAccCode = System.Configuration.ConfigurationManager.AppSettings["GainLoseAcCode"];
                pay_line det         = new pay_line();
                det.AcCode = gainAccCode;
                if (docType.Text == "RE")
                {
                    det.AcSource = "DB";
                }
                else
                {
                    det.AcSource = "CR";
                }
                det.DocType  = docType.Text;
                det.RepType  = docType.Text;
                det.Currency = System.Configuration.ConfigurationManager.AppSettings["Currency"];
                det.DocAmt   = -balAmt;
                det.DocDate  = new DateTime(1900, 1, 1);
                det.DocId    = 0;
                det.DocNo    = "";
                det.ExRate   = 1;
                det.LocAmt   = -balAmt;
                det.Remark1  = "GAIN AND LOSS";
                det.Remark2  = "";
                det.Remark3  = "";
                det.RepId    = SafeValue.SafeInt(oidCtr.Text, 0);
                ASPxTextBox docN = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
                det.RepNo = docN.Text;
                string sql_detCnt = "select count(DocNo) from pay_line where RepId='" + oidCtr.Text + "'";
                int    lineNo     = SafeValue.SafeInt(Manager.ORManager.ExecuteScalar(sql_detCnt), 0) + 1;
                det.RepLineNo = lineNo;
                C2.Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
                C2.Manager.ORManager.PersistChanges(det);
            }
            #endregion
        }
        else if (filter == "Generate")
        {
            string    sql = @"SELECT DocType, DocDate FROM  pay_doc WHERE Id='" + oidCtr.Text + "'";
            DataTable dt  = Manager.ORManager.GetDataSet(sql).Tables[0];
            if (dt.Rows.Count == 1)
            {
                DateTime docDate = SafeValue.SafeDate(dt.Rows[0]["DocDate"], DateTime.Today);
                string   docType = SafeValue.SafeString(dt.Rows[0]["DocType"]);

                string invN = C2Setup.GetNextNo(docType, "AR-RECEIPT", docDate);
                sql = string.Format("Update pay_doc set DocNo='{1}',GenerateInd='Y' where Id='{0}'", oidCtr.Text, invN);
                if (ConnectSql.ExecuteSql(sql) > -1)
                {
                    C2Setup.SetNextNo(docType, "AR-RECEIPT", invN, docDate);
                }
                e.Result = invN;
            }
        }
    }
Ejemplo n.º 24
0
    protected void submit_order(object sender, EventArgs e)
    {
        C2.WhTrans o = new C2.WhTrans();
        o.DoNo           = C2Setup.GetNextNo("", "SaleOrders", DateTime.Today);
        o.DoType         = "SO";
        o.DoStatus       = "Draft";
        o.PartyId        = "";
        o.DoDate         = DateTime.Today;
        o.Currency       = "USD";
        o.ExRate         = 1;
        o.PayTerm        = "CASH";
        o.IncoTerm       = "EXW";
        o.Remark         = "QUICK ORDER";
        o.WareHouseId    = System.Configuration.ConfigurationManager.AppSettings["WareHouse"];
        o.CreateBy       = EzshipHelper.GetUserName();
        o.CreateDateTime = DateTime.Now;
        o.UpdateBy       = "";
        o.UpdateDateTime = DateTime.Now;

        Manager.ORManager.StartTracking(o, Wilson.ORMapper.InitialState.Inserted);
        Manager.ORManager.PersistChanges(o);
        C2Setup.SetNextNo("", "SaleOrders", o.DoNo, DateTime.Today);

        for (int i = 0; i < 50; i++)
        {
            string lineno = string.Format("line{0}", i + 1);

            int    q1    = Helper.Safe.SafeInt(Request[lineno]);
            int    q2    = Helper.Safe.SafeInt(Request[lineno + "a"]);
            int    pq    = Helper.Safe.SafeInt(Request[lineno + "q"]);
            int    whole = Helper.Safe.SafeInt(Request[lineno + "w"]);
            string code  = Helper.Safe.SafeString(Request[lineno + "p"]);
            string lot   = Helper.Safe.SafeString(Request[lineno + "b"]);

            string _sql = "select top 1 * from wh_dodet where dotype='IN' and lotno='" + lot + "'";
            if (lot == "")
            {
                _sql = "select description as des1, att4 as att1, att5 as att2, att6 as att3, att7 as att4, att8 as att5, att9 as att6, uomPacking as uom1,uomWhole as uom2, uomLoose as uom3, uomBase as uom4 from ref_Product where Code='" + code + "'";
            }
            //throw new Exception(_sql);
            DataTable dt1 = Helper.Sql.List(_sql);
            //DataRow dr = dt1.Rows[0];
            //string a = dt1.Rows[0]["LotNo"].ToString();
            //throw new Exception(a);
            //DataRow dr = dt1.Rows[0]; //new DataRow();
            if (q1 > 0)
            {
                C2.WhTransDet d = new C2.WhTransDet();
                d.DoNo   = o.DoNo;
                d.DoType = "SO";
                //d.LineSNo = i + 1;
                d.ProductCode   = code;
                d.LotNo         = lot;
                d.Qty1          = q1;
                d.Qty2          = 0;
                d.Qty3          = 0; //pq * q1;
                d.QtyWholeLoose = 0;
                d.QtyLooseBase  = 0;
                d.LocationCode  = "LWN365";
                d.Des1          = Helper.Safe.SafeString(dt1.Rows[0]["Des1"]);
                d.Uom1          = Helper.Safe.SafeString(dt1.Rows[0]["Uom1"]);
                d.Uom2          = Helper.Safe.SafeString(dt1.Rows[0]["Uom2"]);
                d.Uom3          = Helper.Safe.SafeString(dt1.Rows[0]["Uom3"]);
                d.Uom4          = Helper.Safe.SafeString(dt1.Rows[0]["Uom4"]);
                d.QtyPackWhole  = whole;
                d.Att1          = Helper.Safe.SafeString(dt1.Rows[0]["Att1"]);
                d.Att2          = Helper.Safe.SafeString(dt1.Rows[0]["Att2"]);
                d.Att3          = Helper.Safe.SafeString(dt1.Rows[0]["Att3"]);
                d.Att4          = Helper.Safe.SafeString(dt1.Rows[0]["Att4"]);
                d.Att5          = Helper.Safe.SafeString(dt1.Rows[0]["Att5"]);
                d.Att6          = Helper.Safe.SafeString(dt1.Rows[0]["Att6"]);
                d.Price         = 0;
                d.Packing       = "";
                d.Gst           = 0;
                d.Currency      = "USD";
                d.ExRate        = 1;

                Manager.ORManager.StartTracking(d, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(d);
            }
            if (q2 > 0)
            {
                C2.WhTransDet d = new C2.WhTransDet();
                d.DoNo   = o.DoNo;
                d.DoType = "SO";
                //d.LineSNo = i + 1;
                d.ProductCode   = code;
                d.LotNo         = "";
                d.Qty1          = q2;
                d.Qty2          = 0;
                d.Qty3          = 0; //pq * q1;
                d.QtyPackWhole  = 0;
                d.QtyWholeLoose = 0;
                d.QtyLooseBase  = 0;
                d.LocationCode  = "LWN365";
                d.Des1          = Helper.Safe.SafeString(dt1.Rows[0]["Des1"]);
                d.Uom1          = Helper.Safe.SafeString(dt1.Rows[0]["Uom1"]);
                d.Uom2          = Helper.Safe.SafeString(dt1.Rows[0]["Uom2"]);
                d.Uom3          = Helper.Safe.SafeString(dt1.Rows[0]["Uom3"]);
                d.Uom4          = Helper.Safe.SafeString(dt1.Rows[0]["Uom4"]);
                d.QtyPackWhole  = whole;
                d.Att1          = Helper.Safe.SafeString(dt1.Rows[0]["Att1"]);
                d.Att2          = Helper.Safe.SafeString(dt1.Rows[0]["Att2"]);
                d.Att3          = Helper.Safe.SafeString(dt1.Rows[0]["Att3"]);
                d.Att4          = Helper.Safe.SafeString(dt1.Rows[0]["Att4"]);
                d.Att5          = Helper.Safe.SafeString(dt1.Rows[0]["Att5"]);
                d.Att6          = Helper.Safe.SafeString(dt1.Rows[0]["Att6"]);
                d.Price         = 0;
                d.Packing       = "";
                d.Gst           = 0;
                d.Currency      = "USD";
                d.ExRate        = 1;

                Manager.ORManager.StartTracking(d, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(d);
            }
        }

        Response.Redirect("SoEdit.aspx?no=" + o.DoNo);

        //OpenErpService openErpService = new OpenErpService("http://rejo.ezconnect.asia:99", "oeRejo", "admin", "admin");

        //Partner p = new Partner();
        //p = openErpService.GetEntity<Partner>(a => a.Name.Equals("STARCAST"));

        //SalesOrder order = new SalesOrder();
        //order.Name = "STARCAST:" + DateTime.Now.ToString("MMddHHmmss");
        //order.PartnerId = p.id;
        //order.PartnerInvoiceId = p.id;
        //order.PartnerShippingId = p.id;
        //order.DateOrder = DateTime.Today;
        //order.PriceListId = 1;
        //order.ShopId = 1;
        //openErpService.AddEntity<SalesOrder>(order);

        //int[] prod = { 76, 77, 78, 79, 113,114 };
        //string[] lots = { "SBLA2012", "SBLA2013", "SBLA1675", "SBLA1676", "", "" };
        //double[] qty = { 0,0,0,0,0,0};
        //double[] qtya = { 0, 0, 0, 0, 0, 0 };
        //qty[0] = Helper.Safe.SafeDouble(line1.Text);
        //qty[1] = Helper.Safe.SafeDouble(line2.Text);
        //qty[2] = Helper.Safe.SafeDouble(line3.Text);
        //qty[3] = Helper.Safe.SafeDouble(line4.Text);
        //qty[4] = Helper.Safe.SafeDouble(line5.Text);
        //qty[5] = Helper.Safe.SafeDouble(line6.Text);

        //qtya[0] = Helper.Safe.SafeDouble(line1a.Text);
        //qtya[1] = Helper.Safe.SafeDouble(line2a.Text);
        //qtya[2] = Helper.Safe.SafeDouble(line3a.Text);
        //qtya[3] = Helper.Safe.SafeDouble(line4a.Text);
        //qtya[4] = Helper.Safe.SafeDouble(line5a.Text);
        //qtya[5] = Helper.Safe.SafeDouble(line6a.Text);


        //for (int i = 0; i < prod.Length; i++)
        //{
        //    if (qty[i] > 0)
        //    {
        //        SalesOrderLine line = new SalesOrderLine();
        //        line.OrderId = order.Id;
        //        line.ProductId = prod[i];
        //        Product pr = new Product();
        //        pr = openErpService.GetEntity<Product>(prd => prd.Id == line.ProductId);
        //        line.Name = "[" + lots[i] + "] " + pr.Name;
        //        line.Qantity = qty[i];
        //        openErpService.AddEntity<SalesOrderLine>(line);
        //    }
        //    if (qtya[i] > 0)
        //    {
        //        SalesOrderLine linea = new SalesOrderLine();
        //        linea.OrderId = order.Id;
        //        linea.ProductId = prod[i];
        //        Product pr = new Product();
        //        pr = openErpService.GetEntity<Product>(prd => prd.Id == linea.ProductId);
        //        linea.Name = "[NEW] " + pr.Name;
        //        linea.Qantity = qtya[i];
        //        openErpService.AddEntity<SalesOrderLine>(linea);
        //    }
        //}

        //string temp = "Order Submitted : {0} ";
        //msg.Text = string.Format(temp, order.Name);
        //Helper.Logic.AlertOrder(order.Name);
    }
Ejemplo n.º 25
0
    private void Create_Invoice(DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e, int rowIndex)
    {
        ASPxLabel    lbl_ClientId = this.grid_Transport.FindRowCellTemplateControl(rowIndex, null, "lbl_ClientId") as ASPxLabel;
        ASPxLabel    lbl_JobNo    = this.grid_Transport.FindRowCellTemplateControl(rowIndex, null, "lbl_JobNo") as ASPxLabel;
        TextBox      txt_cntId    = this.grid_Transport.FindRowCellTemplateControl(rowIndex, null, "txt_cntId") as TextBox;
        ASPxDateEdit txt_DocDt    = this.grid_Transport.FindRowCellTemplateControl(rowIndex, null, "txt_DocDt") as ASPxDateEdit;
        string       user         = HttpContext.Current.User.Identity.Name;
        string       acCode       = EzshipHelper.GetAccArCode("", "SGD");
        string       sql          = string.Format(@"select Vessel,Voyage,Pol,Pod,EtaDate from CTM_Job where JobNo='{0}'", lbl_JobNo.Text);
        DataTable    dt_job       = ConnectSql.GetTab(sql);
        DateTime     eta          = DateTime.Today;

        if (dt_job.Rows.Count > 0)
        {
            eta = SafeValue.SafeDate(dt_job.Rows[0]["EtaDate"], DateTime.Today);
        }
        string[] ChgCode_List = { "TRUCKING",          "FUEL",               "DHC",           "PORTENT",     "CMS",           "PSA LOLO",   "",             "", "", ""
                                  ,                    "WEIGNING",           "WASHING",       "REPAIR"
                                  ,                    "DETENTION",          "DEMURRAGE",     "C/S LOLO",    "CNL/SHIPMENT"
                                  ,                    "EMF",                "OTHER",         "",            "PSA STORAGE",   "EX ONE-WAY", "WRONG WEIGHT",
                                  "ELECTRICITY",       "PERMIT",             "EXCHANGE DO",   "SEAL",        "DOCUMENTATION",
                                  "ERP CHARGES",       "HEAVYWEIGHT 23/24T", "PSA FLEXIBOOK", "PSA NO SHOW",
                                  "CHASSIS DEMURRAGE", "PARKING",            "SHIFTING",      "STAND-BY",    "MISC 1",        "MISC 2",     "MISC 3" };

        sql = string.Format(@"select * from CTM_JobDet1 where JobNo='{0}'", lbl_JobNo.Text);
        DataTable dt = ConnectSql.GetTab(sql);

        if (dt.Rows.Count > 0)
        {
            DateTime dtime = txt_DocDt.Date;

            string invN    = C2Setup.GetNextNo("", "AR-IV", dtime);
            string sql_cnt = string.Format(@"select count(*) from XAArInvoice where PartyTo='{0}' and MastRefNo='{1}'", lbl_ClientId.Text, lbl_JobNo.Text);
            int    cnt     = SafeValue.SafeInt(ConnectSql_mb.ExecuteScalar(sql_cnt), 0);
            string des     = "";
            if (cnt == 0)
            {
                #region Inv Mast

                sql = string.Format(@"insert into XAArInvoice (DocType,DocDate,PartyTo,DocNo,AcYear,AcPeriod,Term,DocDueDate,Description,
CurrencyId,MastType,ExRate,ExportInd,CancelDate,CancelInd,UserId,EntryDate,Eta,AcCode,AcSource,MastRefNo)
values('IV','{5:yyyy-MM-dd}','{4}','{0}','{6}','{7}','CASH','{5:yyyy-MM-dd}','',
'SGD','CTM',1,'N','19000101','N','{1}',getdate(),'17530101','{2}','DB','{3}')
select @@IDENTITY", invN, user, acCode, lbl_JobNo.Text, lbl_ClientId.Text, dtime, dtime.Year, dtime.Month);
                string docId = ConnectSql_mb.ExecuteScalar(sql);
                C2Setup.SetNextNo("", "AR-IV", invN, dtime);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string cntNo   = SafeValue.SafeString(dt.Rows[i]["ContainerNo"]);
                    string cntType = SafeValue.SafeString(dt.Rows[i]["ContainerType"]);
                    //if()
                    string sql_part1 = string.Format(@"insert into XAArInvoiceDet (DocId,DocNo,DocType,DocLineNo,AcCode,AcSource,ChgCode,ChgDes1,
GstType,Qty,Price,Unit,Currency,ExRate,Gst,GstAmt,DocAmt,LocAmt,LineLocAmt,MastRefNo,JobRefNo,MastType) 
values");
                    sql  = "";
                    des += cntNo + " / " + cntType + "   ";
                    for (int j = 0, j1 = 0; j < ChgCode_List.Length; j++)
                    {
                        string sql_chgCode = string.Format(@"select top 1 ChgcodeId,ChgcodeDes from XXChgCode where ChgcodeDes like '{0}%'", ChgCode_List[j]);
                        if (ChgCode_List[j].Equals("TRUCKING"))
                        {
                            sql_chgCode = string.Format(@"select top 1 ChgcodeId,ChgcodeDes from XXChgCode where ChgcodeDes like '{0}%'", ChgCode_List[j] + " " + cntType.Substring(0, 2));
                        }
                        DataTable dt_chgCode = ConnectSql.GetTab(sql_chgCode);
                        string    chgCodeId  = "";
                        string    note       = "";
                        if (dt_chgCode.Rows.Count > 0)
                        {
                            chgCodeId = SafeValue.SafeString(dt_chgCode.Rows[0]["ChgcodeId"]);
                            note      = SafeValue.SafeString(dt_chgCode.Rows[0]["ChgcodeDes"]);
                        }
                        else
                        {
                            chgCodeId = ChgCode_List[j];
                        }
                        if (!ChgCode_List[j].Equals("") && !ChgCode_List[j].Equals("MISC") && !ChgCode_List[j].Equals("REMARK"))
                        {
                            j1++;

                            decimal temp_fee = SafeValue.SafeDecimal(dt.Rows[i]["Fee" + (j + 1)]);
                            if (temp_fee != 0)
                            {
                                note += dt.Rows[i]["FeeNote" + (j + 1)].ToString();
                                string sql_part2 = string.Format(@"('{0}','{1}','IV','{2}','31','CR','{3}','{4}','Z',1,{5},'','SGD',1,0,0,{5},{5},{5},'{6}','{7}','{8}')", docId, invN, j1, chgCodeId, note, temp_fee, lbl_JobNo.Text, cntNo, "CTM");
                                sql += sql.Length > 0 ? "," + sql_part2 : sql_part2;
                            }
                        }
                    }
                    if (sql.Length > 0)
                    {
                        sql = sql_part1 + sql;
                        int re = ConnectSql.ExecuteSql(sql);
                        e.Result = invN;
                        des      = "Vessel/Voy:" + dt_job.Rows[0]["Vessel"] + " / " + dt_job.Rows[0]["Voyage"] + "\n" + "Pol/Pod:" + dt_job.Rows[0]["Pol"] + " / " + dt_job.Rows[0]["Pod"] + "\n" + "Eta:" + eta.ToString("dd.MM.yy") + "\n" + "Container No: " + des;
                        UpdateMaster(SafeValue.SafeInt(docId, 0), des);
                    }
                }
                #endregion
            }
            else
            {
                string    sql_id     = string.Format(@"select SequenceId,DocNo from XAArInvoice where PartyTo='{0}'", lbl_ClientId.Text);
                DataTable dt_inv     = ConnectSql.GetTab(sql_id);
                int       sequenceId = 0;
                if (dt_inv.Rows.Count > 0)
                {
                    sequenceId = SafeValue.SafeInt(dt_inv.Rows[0]["SequenceId"], 0);
                    invN       = SafeValue.SafeString(dt_inv.Rows[0]["DocNo"]);
                }
                #region Inv Det
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string cntNo   = SafeValue.SafeString(dt.Rows[i]["ContainerNo"]);
                    string cntType = SafeValue.SafeString(dt.Rows[i]["ContainerType"]);

                    //if()
                    string sql_part1 = string.Format(@"insert into XAArInvoiceDet (DocId,DocNo,DocType,DocLineNo,AcCode,AcSource,ChgCode,ChgDes1,
GstType,Qty,Price,Unit,Currency,ExRate,Gst,GstAmt,DocAmt,LocAmt,LineLocAmt,MastRefNo,JobRefNo,MastType)
values");
                    sql  = "";
                    des += cntNo + " / " + cntType + "     ";
                    for (int j = 0, j1 = 0; j < ChgCode_List.Length; j++)
                    {
                        sql_cnt = string.Format(@"select count(*) from XAArInvoiceDet where ChgCode='{0}' and JobRefNo='{1}'", ChgCode_List[j], cntNo);
                        cnt     = SafeValue.SafeInt(ConnectSql_mb.ExecuteScalar(sql_cnt), 0);
                        if (cnt == 0)
                        {
                            string sql_chgCode = string.Format(@"select top 1 ChgcodeId,ChgcodeDes from XXChgCode where ChgcodeDes like '{0}%'", ChgCode_List[j]);
                            if (ChgCode_List[j].Equals("TRUCKING"))
                            {
                                sql_chgCode = string.Format(@"select top 1 ChgcodeId,ChgcodeDes from XXChgCode where ChgcodeDes like '{0}%'", ChgCode_List[j] + " " + cntType.Substring(0, 2));
                            }
                            DataTable dt_chgCode = ConnectSql.GetTab(sql_chgCode);
                            string    chgCodeId  = "";
                            string    note       = "";
                            if (dt_chgCode.Rows.Count > 0)
                            {
                                chgCodeId = SafeValue.SafeString(dt_chgCode.Rows[0]["ChgcodeId"]);
                                note      = SafeValue.SafeString(dt_chgCode.Rows[0]["ChgcodeDes"]);
                            }
                            else
                            {
                                chgCodeId = ChgCode_List[j];
                            }
                            if (!ChgCode_List[j].Equals("") && !ChgCode_List[j].Equals("MISC") && !ChgCode_List[j].Equals("REMARK"))
                            {
                                j1++;

                                decimal temp_fee = SafeValue.SafeDecimal(dt.Rows[i]["Fee" + (j + 1)]);
                                if (temp_fee != 0)
                                {
                                    note += dt.Rows[i]["FeeNote" + (j + 1)].ToString();
                                    string sql_part2 = string.Format(@"('{0}','{1}','IV','{2}','','CR','{3}','{4}','Z',1,{5},'','SGD',1,0,0,{5},{5},{5},'{6}','{7}','{8}')", sequenceId, invN, j1, chgCodeId, note, temp_fee, lbl_JobNo.Text, cntNo, "CTM");
                                    sql += sql.Length > 0 ? "," + sql_part2 : sql_part2;
                                }
                            }
                        }
                    }
                    if (sql.Length > 0)
                    {
                        sql = sql_part1 + sql;
                        int re = ConnectSql.ExecuteSql(sql);
                        e.Result = invN;
                        des      = "Vessel/Voy:" + dt_job.Rows[0]["Vessel"] + " / " + dt_job.Rows[0]["Voyage"] + "\n" + "Pol/Pod:" + dt_job.Rows[0]["Pol"] + " / " + dt_job.Rows[0]["Pod"] + "\n" + "Eta:" + eta.ToString("dd.MM.yy") + "\n" + "Container No: " + des;
                        UpdateMaster(SafeValue.SafeInt(sequenceId, 0), des);
                    }
                }
                #endregion
            }
        }
    }
Ejemplo n.º 26
0
    protected string SaveJob()
    {
        try
        {
            ASPxPageControl            pageControl = this.grid_Issue.FindEditFormTemplateControl("pageControl_Hbl") as ASPxPageControl;
            ASPxTextBox                DoNo        = grid_Issue.FindEditFormTemplateControl("txt_JobNo") as ASPxTextBox;
            ASPxTextBox                txt_Id      = grid_Issue.FindEditFormTemplateControl("txt_Id") as ASPxTextBox;
            string                     pId         = SafeValue.SafeString(txt_Id.Text, "");
            Wilson.ORMapper.OPathQuery query       = new Wilson.ORMapper.OPathQuery(typeof(JobSchedule), "Id='" + pId + "'");
            JobSchedule                job         = C2.Manager.ORManager.GetObject(query) as JobSchedule;
            ASPxDateEdit               issueDate   = grid_Issue.FindEditFormTemplateControl("date_IssueDate") as ASPxDateEdit;
            bool isNew = false;
            //const string runType = "DOOUT";
            string issueN = "";
            if (job == null)
            {
                job         = new JobSchedule();
                isNew       = true;
                issueN      = C2Setup.GetNextNo("", "JobOrder", issueDate.Date);
                job.JobDate = issueDate.Date;
            }

            ASPxDateEdit doDate = grid_Issue.FindEditFormTemplateControl("date_IssueDate") as ASPxDateEdit;
            if (doDate != null)
            {
                job.JobDate = doDate.Date;
            }

            ASPxComboBox cmb_Status = grid_Issue.FindEditFormTemplateControl("cmb_Status") as ASPxComboBox;
            if (cmb_Status != null)
            {
                job.JobStage = SafeValue.SafeString(cmb_Status.Value);
            }
            ASPxComboBox cmb_JobType = grid_Issue.FindEditFormTemplateControl("cmb_JobType") as ASPxComboBox;
            if (cmb_JobType != null)
            {
                job.JobType = SafeValue.SafeString(cmb_JobType.Value);
            }
            //Main Info
            ASPxButtonEdit txt_CustomerId = grid_Issue.FindEditFormTemplateControl("txt_CustomerId") as ASPxButtonEdit;
            if (txt_CustomerId != null)
            {
                job.CustomerId = txt_CustomerId.Text;
            }
            ASPxTextBox txt_CustomerName = grid_Issue.FindEditFormTemplateControl("txt_CustomerName") as ASPxTextBox;
            if (txt_CustomerName != null)
            {
                job.CustomerName = txt_CustomerName.Text;
            }
            ASPxMemo memo_Address = grid_Issue.FindEditFormTemplateControl("memo_Address") as ASPxMemo;
            if (memo_Address != null)
            {
                job.CustomerAdd = memo_Address.Text;
            }

            ASPxTextBox txt_PostalCode = grid_Issue.FindEditFormTemplateControl("txt_PostalCode") as ASPxTextBox;
            if (txt_PostalCode != null)
            {
                job.Postalcode = txt_PostalCode.Text;
            }
            ASPxTextBox txt_Contact = grid_Issue.FindEditFormTemplateControl("txt_Contact") as ASPxTextBox;
            if (txt_Contact != null)
            {
                job.Contact = txt_Contact.Text;
            }
            ASPxTextBox txt_Tel = grid_Issue.FindEditFormTemplateControl("txt_Tel") as ASPxTextBox;
            if (txt_Tel != null)
            {
                job.Tel = txt_Tel.Text;
            }
            ASPxTextBox txt_Email = grid_Issue.FindEditFormTemplateControl("txt_Email") as ASPxTextBox;
            if (txt_Email != null)
            {
                job.Email = txt_Email.Text;
            }
            ASPxTextBox txt_Fax = grid_Issue.FindEditFormTemplateControl("txt_Fax") as ASPxTextBox;
            if (txt_Fax != null)
            {
                job.Fax = txt_Fax.Text;
            }
            ASPxMemo remark = grid_Issue.FindEditFormTemplateControl("txt_Remark") as ASPxMemo;
            if (remark != null)
            {
                job.Remark = remark.Text;
            }
            ASPxButtonEdit currency = grid_Issue.FindEditFormTemplateControl("txt_Currency") as ASPxButtonEdit;
            if (currency != null)
            {
                job.Currency = currency.Text;
            }
            ASPxSpinEdit exRate = grid_Issue.FindEditFormTemplateControl("spin_ExRate") as ASPxSpinEdit;
            if (exRate != null)
            {
                job.ExRate = SafeValue.SafeDecimal(exRate.Value, 1);
            }
            ASPxComboBox payTerm = grid_Issue.FindEditFormTemplateControl("cmb_PayTerm") as ASPxComboBox;
            if (payTerm != null)
            {
                job.PayTerm = payTerm.Text;
            }
            ASPxDateEdit date_ExpiryDate = grid_Issue.FindEditFormTemplateControl("date_ExpiryDate") as ASPxDateEdit;
            if (date_ExpiryDate != null)
            {
                job.ExpiryDate = date_ExpiryDate.Date;
            }


            ASPxMemo txt_PackRemark = grid_Issue.FindEditFormTemplateControl("txt_PackRemark") as ASPxMemo;
            if (txt_PackRemark != null)
            {
                job.PackRmk = txt_PackRemark.Text;
            }
            ASPxMemo txt_MoveRemark = grid_Issue.FindEditFormTemplateControl("txt_MoveRemark") as ASPxMemo;
            if (txt_MoveRemark != null)
            {
                job.MoveRmk = txt_MoveRemark.Text;
            }

            ASPxButtonEdit txt_WareHouseId = grid_Issue.FindEditFormTemplateControl("txt_WareHouseId") as ASPxButtonEdit;
            if (txt_WareHouseId != null)
            {
                job.WareHouseId = txt_WareHouseId.Text;
            }
            ASPxButtonEdit btn_OriginPort = grid_Issue.FindEditFormTemplateControl("btn_OriginPort") as ASPxButtonEdit;
            if (btn_OriginPort != null)
            {
                job.OriginPort = btn_OriginPort.Text;
            }
            ASPxButtonEdit btn_DestinationPort = grid_Issue.FindEditFormTemplateControl("btn_DestinationPort") as ASPxButtonEdit;
            if (btn_DestinationPort != null)
            {
                job.DestinationPort = btn_DestinationPort.Text;
            }
            ASPxMemo memo_Address1 = grid_Issue.FindEditFormTemplateControl("memo_Address1") as ASPxMemo;
            if (memo_Address1 != null)
            {
                job.OriginAdd = memo_Address1.Text;
            }
            ASPxMemo memo_Address2 = grid_Issue.FindEditFormTemplateControl("memo_Address2") as ASPxMemo;
            if (memo_Address2 != null)
            {
                job.DestinationAdd = memo_Address2.Text;
            }
            ASPxSpinEdit spin_Volumne = grid_Issue.FindEditFormTemplateControl("spin_Volumne") as ASPxSpinEdit;
            if (spin_Volumne != null)
            {
                job.Volumne = SafeValue.SafeDecimal(spin_Volumne.Value);
            }
            ASPxMemo memo_Description = grid_Issue.FindEditFormTemplateControl("memo_Description") as ASPxMemo;
            if (memo_Description != null)
            {
                job.ItemDes = memo_Description.Text;
            }
            ASPxTextBox memo_Volumn = grid_Issue.FindEditFormTemplateControl("memo_Volumn") as ASPxTextBox;
            if (memo_Volumn != null)
            {
                job.VolumneRmk = memo_Description.Text;
            }
            ASPxSpinEdit spin_HeadCount = grid_Issue.FindEditFormTemplateControl("spin_HeadCount") as ASPxSpinEdit;
            if (spin_HeadCount != null)
            {
                job.HeadCount = SafeValue.SafeInt(spin_HeadCount.Value, 0);
            }

            ASPxDateEdit date_Pack = grid_Issue.FindEditFormTemplateControl("date_Pack") as ASPxDateEdit;
            if (date_Pack != null)
            {
                job.PackDate = date_Pack.Date;
            }
            ASPxComboBox cmb_Via = grid_Issue.FindEditFormTemplateControl("cmb_Via") as ASPxComboBox;
            if (cmb_Via != null)
            {
                job.ViaWh = cmb_Via.Text;
            }
            ASPxDateEdit date_StorageStartDate = grid_Issue.FindEditFormTemplateControl("date_StorageStartDate") as ASPxDateEdit;
            if (date_StorageStartDate != null)
            {
                job.StorageStartDate = date_StorageStartDate.Date;
            }
            ASPxSpinEdit spin_StorageFreeDays = grid_Issue.FindEditFormTemplateControl("spin_StorageFreeDays") as ASPxSpinEdit;
            if (spin_StorageFreeDays != null)
            {
                job.StorageFreeDays = SafeValue.SafeInt(spin_StorageFreeDays.Value, 0);
            }
            ASPxSpinEdit spin_STotalDays = grid_Issue.FindEditFormTemplateControl("spin_STotalDays") as ASPxSpinEdit;
            if (spin_STotalDays != null)
            {
                job.StorageTotalDays = Helper.Safe.SafeInt(spin_STotalDays.Value);
            }
            ASPxTextBox txt_TripNo = grid_Issue.FindEditFormTemplateControl("txt_TripNo") as ASPxTextBox;
            if (txt_TripNo != null)
            {
                job.TripNo = txt_TripNo.Text;
            }
            ASPxDateEdit date_MoveDate = grid_Issue.FindEditFormTemplateControl("date_MoveDate") as ASPxDateEdit;
            if (date_MoveDate != null)
            {
                job.MoveDate = date_MoveDate.Date;
            }
            ASPxSpinEdit spin_Charges = grid_Issue.FindEditFormTemplateControl("spin_Charges") as ASPxSpinEdit;
            if (spin_Charges != null)
            {
                job.Charges = SafeValue.SafeDecimal(spin_Charges.Value);
            }
            ASPxButtonEdit btn_PortOfEntry = grid_Issue.FindEditFormTemplateControl("btn_PortOfEntry") as ASPxButtonEdit;
            if (btn_PortOfEntry != null)
            {
                job.EntryPort = btn_PortOfEntry.Text;
            }
            ASPxComboBox txt_Mode = grid_Issue.FindEditFormTemplateControl("cmb_Mode") as ASPxComboBox;
            if (txt_Mode != null)
            {
                job.Mode = txt_Mode.Text;
            }
            ASPxDateEdit date_Eta = grid_Issue.FindEditFormTemplateControl("date_Eta") as ASPxDateEdit;
            if (date_Eta != null)
            {
                job.Eta = date_Eta.Date;
            }
            ASPxTextBox txt_TruckNo = grid_Issue.FindEditFormTemplateControl("txt_TruckNo") as ASPxTextBox;
            if (txt_TruckNo != null)
            {
                job.TruckNo = txt_TruckNo.Text;
            }
            ASPxButtonEdit btn_OriginCity = grid_Issue.FindEditFormTemplateControl("btn_OriginCity") as ASPxButtonEdit;
            if (btn_OriginCity != null)
            {
                job.OriginCity = btn_OriginCity.Text;
            }
            ASPxButtonEdit btn_DestCity = grid_Issue.FindEditFormTemplateControl("btn_DestCity") as ASPxButtonEdit;
            if (btn_DestCity != null)
            {
                job.DestCity = btn_DestCity.Text;
            }
            ASPxTextBox txt_OriginPostal = grid_Issue.FindEditFormTemplateControl("txt_OriginPostal") as ASPxTextBox;
            if (txt_OriginPostal != null)
            {
                job.OriginPostal = txt_OriginPostal.Text;
            }
            ASPxTextBox txt_DestPostal = grid_Issue.FindEditFormTemplateControl("txt_DestPostal") as ASPxTextBox;
            if (txt_DestPostal != null)
            {
                job.DestPostal = txt_DestPostal.Text;
            }
            ASPxComboBox cmb_ServiceType = grid_Issue.FindEditFormTemplateControl("cmb_ServiceType") as ASPxComboBox;
            if (cmb_ServiceType != null)
            {
                job.ServiceType = cmb_ServiceType.Text;
            }
            //Additional

            //ASPxComboBox cmb_FullPacking = pageControl.FindControl("cmb_FullPacking") as ASPxComboBox;
            //if (cmb_FullPacking != null)
            //    job.Item1 = SafeValue.SafeString(cmb_FullPacking.Value);
            //ASPxComboBox cmb_UnFull = pageControl.FindControl("cmb_UnFull") as ASPxComboBox;
            //if (cmb_UnFull != null)
            //    job.Item2 = SafeValue.SafeString(cmb_UnFull.Value);
            //ASPxTextBox txt_Details = pageControl.FindControl("txt_Details") as ASPxTextBox;
            //if (txt_Details != null)
            //    job.ItemDetail1 = txt_Details.Text;
            //ASPxTextBox txt_UnpackDetails = pageControl.FindControl("txt_UnpackDetails") as ASPxTextBox;
            //if (txt_UnpackDetails != null)
            //    job.ItemDetail2 = txt_UnpackDetails.Text;

            //ASPxComboBox cmb_Insurance = pageControl.FindControl("cmb_Insurance") as ASPxComboBox;
            //if (cmb_Insurance != null)
            //    job.Item3 = SafeValue.SafeString(cmb_Insurance.Value);
            //ASPxTextBox txt_Percentage = pageControl.FindControl("txt_Percentage") as ASPxTextBox;
            //if (txt_Percentage != null)
            //    job.ItemValue3 = txt_Percentage.Text;
            //ASPxTextBox txt_Value = pageControl.FindControl("txt_Value") as ASPxTextBox;
            //if (txt_Value != null)
            //    job.ItemData3 = txt_Value.Text;
            //ASPxSpinEdit txt_Premium = pageControl.FindControl("txt_Premium") as ASPxSpinEdit;
            //if (txt_Premium != null)
            //    job.ItemPrice3 = SafeValue.SafeDecimal(txt_Premium.Text);

            //ASPxComboBox cmb_PianoApply = pageControl.FindControl("cmb_PianoApply") as ASPxComboBox;
            //if (cmb_PianoApply != null)
            //    job.Item4 = SafeValue.SafeString(cmb_PianoApply.Value);
            //ASPxTextBox txt_PainoDetails = pageControl.FindControl("txt_PainoDetails") as ASPxTextBox;
            //if (txt_PainoDetails != null)
            //    job.ItemDetail4 = txt_PainoDetails.Text;
            //ASPxSpinEdit spin_Charges1 = pageControl.FindControl("spin_Charges1") as ASPxSpinEdit;
            //if (spin_Charges1 != null)
            //    job.ItemPrice4 = SafeValue.SafeDecimal(spin_Charges1.Value);

            //ASPxComboBox cmb_Safe = pageControl.FindControl("cmb_Safe") as ASPxComboBox;
            //if (cmb_Safe != null)
            //    job.Item5 = cmb_Safe.Text;
            //ASPxTextBox txt_Brand = pageControl.FindControl("txt_Brand") as ASPxTextBox;
            //if (txt_Brand != null)
            //    job.ItemValue5 = SafeValue.SafeString(txt_Brand.Value);
            //ASPxSpinEdit spin_Weight = pageControl.FindControl("spin_Weight") as ASPxSpinEdit;
            //if (spin_Weight != null)
            //    job.ItemPrice5 = SafeValue.SafeDecimal(spin_Weight.Value);

            //ASPxComboBox cmb_Crating = pageControl.FindControl("cmb_Crating") as ASPxComboBox;
            //if (cmb_Crating != null)
            //    job.Item6 = SafeValue.SafeString(cmb_Crating.Value);
            //ASPxTextBox txt_Details1 = pageControl.FindControl("txt_Details1") as ASPxTextBox;
            //if (txt_Details1 != null)
            //    job.ItemDetail6 = txt_Details1.Text;
            //ASPxSpinEdit spin_Charges2 = pageControl.FindControl("spin_Charges2") as ASPxSpinEdit;
            //if (spin_Charges2 != null)
            //    job.ItemPrice6 = SafeValue.SafeDecimal(spin_Charges2.Value);

            //ASPxComboBox cmb_Handyman = pageControl.FindControl("cmb_Handyman") as ASPxComboBox;
            //if (cmb_Handyman != null)
            //    job.Item7 = SafeValue.SafeString(cmb_Handyman.Value);
            //ASPxComboBox cmb_Complimentory = pageControl.FindControl("cmb_Complimentory") as ASPxComboBox;
            //if (cmb_Complimentory != null)
            //    job.ItemValue7 = SafeValue.SafeString(cmb_Complimentory.Value);
            //ASPxTextBox txt_Details2 = pageControl.FindControl("txt_Details2") as ASPxTextBox;
            //if (txt_Details2 != null)
            //    job.ItemDetail7 = txt_Details2.Text;
            //ASPxSpinEdit spin_Charges3 = pageControl.FindControl("spin_Charges3") as ASPxSpinEdit;
            //if (spin_Charges3 != null)
            //    job.ItemPrice7 = SafeValue.SafeDecimal(spin_Charges3.Value);

            //ASPxComboBox cmb_Maid = pageControl.FindControl("cmb_Maid") as ASPxComboBox;
            //if (cmb_Maid != null)
            //    job.Item8 = SafeValue.SafeString(cmb_Maid.Value);
            //ASPxComboBox cmb_Complimentory1 = pageControl.FindControl("cmb_Complimentory1") as ASPxComboBox;
            //if (cmb_Complimentory1 != null)
            //    job.ItemValue8 = SafeValue.SafeString(cmb_Complimentory1.Value);
            //ASPxTextBox txt_Details3 = pageControl.FindControl("txt_Details3") as ASPxTextBox;
            //if (txt_Details3 != null)
            //    job.ItemDetail8 = txt_Details3.Text;
            //ASPxSpinEdit spin_Charges4 = pageControl.FindControl("spin_Charges4") as ASPxSpinEdit;
            //if (spin_Charges4 != null)
            //    job.ItemPrice8 = SafeValue.SafeDecimal(spin_Charges4.Value);

            //ASPxComboBox cmb_Shifting = pageControl.FindControl("cmb_Shifting") as ASPxComboBox;
            //if (cmb_Shifting != null)
            //    job.Item9 = SafeValue.SafeString(cmb_Shifting.Value);
            //ASPxComboBox cmb_Complimentory2 = pageControl.FindControl("cmb_Complimentory2") as ASPxComboBox;
            //if (cmb_Complimentory2 != null)
            //    job.ItemValue9 = SafeValue.SafeString(cmb_Complimentory2.Value);
            //ASPxTextBox txt_Details4 = pageControl.FindControl("txt_Details4") as ASPxTextBox;
            //if (txt_Details4 != null)
            //    job.ItemDetail9 = txt_Details4.Text;
            //ASPxSpinEdit spin_Charges5 = pageControl.FindControl("spin_Charges5") as ASPxSpinEdit;
            //if (spin_Charges5 != null)
            //    job.ItemPrice9 = SafeValue.SafeDecimal(spin_Charges5.Value);

            //ASPxComboBox cmb_Disposal = pageControl.FindControl("cmb_Disposal") as ASPxComboBox;
            //if (cmb_Disposal != null)
            //    job.Item10 = cmb_Disposal.Text;
            //ASPxComboBox cmb_Complimentory3 = pageControl.FindControl("cmb_Complimentory3") as ASPxComboBox;
            //if (cmb_Complimentory3 != null)
            //    job.ItemValue10 = cmb_Complimentory3.Text;
            //ASPxTextBox txt_Details5 = pageControl.FindControl("txt_Details5") as ASPxTextBox;
            //if (txt_Details5 != null)
            //    job.ItemDetail10 = txt_Details5.Text;
            //ASPxSpinEdit spin_Charges6 = pageControl.FindControl("spin_Charges6") as ASPxSpinEdit;
            //if (spin_Charges6 != null)
            //    job.ItemPrice10 = SafeValue.SafeDecimal(spin_Charges6.Value);

            //ASPxComboBox cmb_PickUp = pageControl.FindControl("cmb_PickUp") as ASPxComboBox;
            //if (cmb_PickUp != null)
            //    job.Item11 = SafeValue.SafeString(cmb_PickUp.Value);
            //ASPxTextBox txt_Details6 = pageControl.FindControl("txt_Details6") as ASPxTextBox;
            //if (txt_Details6 != null)
            //    job.ItemDetail11 = txt_Details6.Text;

            //ASPxComboBox cmb_Additional = pageControl.FindControl("cmb_Additional") as ASPxComboBox;
            //if (cmb_Additional != null)
            //    job.Item12 = cmb_Additional.Text;
            //ASPxTextBox txt_Details7 = pageControl.FindControl("txt_Details7") as ASPxTextBox;
            //if (txt_Details7 != null)
            //    job.ItemDetail12 = txt_Details7.Text;

            //ASPxComboBox cmb_BadAccess = pageControl.FindControl("cmb_BadAccess") as ASPxComboBox;
            //if (cmb_BadAccess != null)
            //    job.Item13 = SafeValue.SafeString(cmb_BadAccess.Value);
            //ASPxComboBox cmb_Origin = pageControl.FindControl("cmb_Origin") as ASPxComboBox;
            //if (cmb_Origin != null)
            //    job.ItemValue13 = cmb_Origin.Text;
            //ASPxComboBox cmb_Destination = pageControl.FindControl("cmb_Destination") as ASPxComboBox;
            //if (cmb_Destination != null)
            //    job.ItemData13 = SafeValue.SafeString(cmb_Destination.Value);

            //ASPxComboBox cmb_Storage = pageControl.FindControl("cmb_Storage") as ASPxComboBox;
            //if (cmb_Storage != null)
            //    job.Item14 = SafeValue.SafeString(cmb_Storage.Value);
            //ASPxComboBox cmb_Complimentory4 = pageControl.FindControl("cmb_Complimentory4") as ASPxComboBox;
            //if (cmb_Complimentory4 != null)
            //    job.ItemValue14 = SafeValue.SafeString(cmb_Complimentory4.Value);
            //ASPxTextBox txt_Details8 = pageControl.FindControl("txt_Details8") as ASPxTextBox;
            //if (txt_Details8 != null)
            //    job.ItemDetail14 = txt_Details8.Text;
            //ASPxSpinEdit spin_Charges7 = pageControl.FindControl("spin_Charges7") as ASPxSpinEdit;
            //if (spin_Charges7 != null)
            //    job.ItemPrice14 = SafeValue.SafeDecimal(spin_Charges7.Value);

            //ASPxTextBox txt_How = pageControl.FindControl("txt_How") as ASPxTextBox;
            //if (txt_How != null)
            //    job.Answer1 = txt_How.Text;
            //ASPxTextBox txt_Other = pageControl.FindControl("txt_Other") as ASPxTextBox;
            //if (txt_Other != null)
            //    job.Answer2 = txt_Other.Text;
            //ASPxTextBox txt_Move = pageControl.FindControl("txt_Move") as ASPxTextBox;
            //if (txt_Move != null)
            //    job.Answer3 = txt_Move.Text;
            //ASPxTextBox txt_UnsuccessRemark = pageControl.FindControl("txt_UnsuccessRemark") as ASPxTextBox;
            //if (txt_UnsuccessRemark != null)
            //    job.Answer4 = txt_UnsuccessRemark.Text;
            //ASPxComboBox cmb_WorkStatus = grid_Issue.FindEditFormTemplateControl("cmb_WorkStatus") as ASPxComboBox;
            //if (cmb_WorkStatus != null)
            //    job.WorkStatus = SafeValue.SafeString(cmb_WorkStatus.Value);



            //Quotation
            //ASPxHtmlEditor txt_Attention1 = pageControl.FindControl("txt_Attention1") as ASPxHtmlEditor;
            //if (txt_Attention1 != null)
            //    job.Attention1 = txt_Attention1.Html;
            //ASPxHtmlEditor txt_Attention2 = pageControl.FindControl("txt_Attention2") as ASPxHtmlEditor;
            //if (txt_Attention2 != null)
            //    job.Attention2 = txt_Attention2.Html;
            //ASPxHtmlEditor txt_Attention3 = pageControl.FindControl("txt_Attention3") as ASPxHtmlEditor;
            //if (txt_Attention3 != null)
            //    job.Attention3 = txt_Attention3.Html;
            //ASPxHtmlEditor txt_Attention4 = pageControl.FindControl("txt_Attention4") as ASPxHtmlEditor;
            //if (txt_Attention4 != null)
            //    job.Attention4 = txt_Attention4.Html;
            //ASPxHtmlEditor txt_Attention5 = pageControl.FindControl("txt_Attention5") as ASPxHtmlEditor;
            //if (txt_Attention5 != null)
            //    job.Attention5 = txt_Attention5.Html;

            //if (cmb_Status.Text == "Job Confirmation")
            //{
            //    job.WorkStatus = "Pending";
            //}
            //ASPxComboBox cmb_SalesId = grid_Issue.FindEditFormTemplateControl("cmb_SalesId") as ASPxComboBox;
            //if (cmb_SalesId != null)
            //    job.Value4 = cmb_SalesId.Text;


            //if (cmb_Status.Text == "Job Confirmation")
            //{
            //    job.WorkStatus = "Pending";
            //}
            //if (job.JobStage == "Customer Inquiry")
            //{
            //    job.DateTime1 = DateTime.Now;

            //}



            //if (job.WorkStatus == "Costing")
            //{
            //    job.DateTime3 = DateTime.Now;

            //}
            //if (job.WorkStatus == "Quotation")
            //{
            //    job.DateTime4 = DateTime.Now;

            //}
            //if (job.WorkStatus == "Job Confirmation")
            //{
            //    job.DateTime5 = DateTime.Now;

            //}
            //if (job.WorkStatus == "Billing")
            //{
            //    job.DateTime6 = DateTime.Now;

            //}
            //if (job.WorkStatus == "Job Completion")
            //{
            //    job.DateTime7 = DateTime.Now;

            //}
            //if (job.WorkStatus == "Job Close")
            //{
            //    job.DateTime8 = DateTime.Now;

            //}
            //ASPxDateEdit date_DateTime2 = grid_Issue.FindEditFormTemplateControl("date_DateTime2") as ASPxDateEdit;
            //if (date_DateTime2 != null)
            //{
            //    if (!date_DateTime2.Date.IsDaylightSavingTime())
            //        job.DateTime2 = date_DateTime2.Date;
            //    else
            //        job.DateTime2 = DateTime.Now;
            //}
            //ASPxMemo memo_Notes = pageControl.FindControl("memo_Notes") as ASPxMemo;
            //if (memo_Notes != null)
            //    job.Notes = memo_Notes.Text;
            string userId = HttpContext.Current.User.Identity.Name;
            if (isNew)
            {
                job.CreateBy       = userId;
                job.CreateDateTime = DateTime.Now;
                job.UpdateBy       = userId;
                job.UpdateDateTime = DateTime.Now;
                job.JobNo          = issueN;
                Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(job);
                C2Setup.SetNextNo("", "JobOrder", issueN, issueDate.Date);
            }
            else
            {
                job.UpdateBy       = userId;
                job.UpdateDateTime = DateTime.Now;
                bool isAddLog = false;
                if (job.JobStatus == SafeValue.SafeString(ConnectSql.ExecuteScalar("Select JobStatus from JobSchedule where JobNo='" + job.JobNo + "'")))
                {
                }
                else
                {
                    isAddLog = true;
                }
                Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Updated);
                Manager.ORManager.PersistChanges(job);
                if (isAddLog)
                {
                    EzshipLog.Log(job.JobNo, "", "JO", job.JobStatus);
                }
            }
            Session["SoWhere"] = "JobNo='" + job.JobNo + "'";
            this.dsSchedule.FilterExpression = Session["SoWhere"].ToString();
            if (this.grid_Issue.GetRow(0) != null)
            {
                this.grid_Issue.StartEdit(0);
            }

            return(job.JobNo);
        }
        catch (Exception ex) { throw new Exception(ex.Message + ex.StackTrace); }
        return("");
    }
Ejemplo n.º 27
0
    private void SaveAndUpdate()
    {
        ASPxTextBox  invNCtr     = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;
        ASPxComboBox partyTo     = this.ASPxGridView1.FindEditFormTemplateControl("cmb_PartyTo") as ASPxComboBox;
        ASPxTextBox  docN        = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
        ASPxComboBox docType     = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox;
        ASPxDateEdit docDate     = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocDt") as ASPxDateEdit;
        ASPxMemo     remarks1    = this.ASPxGridView1.FindEditFormTemplateControl("txt_Remarks1") as ASPxMemo;
        ASPxComboBox termId      = this.ASPxGridView1.FindEditFormTemplateControl("txt_TermId") as ASPxComboBox;
        ASPxDateEdit dueDt       = this.ASPxGridView1.FindEditFormTemplateControl("txt_DueDt") as ASPxDateEdit;
        ASPxTextBox  docCurr     = this.ASPxGridView1.FindEditFormTemplateControl("txt_Currency") as ASPxTextBox;
        ASPxSpinEdit exRate      = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocExRate") as ASPxSpinEdit;
        ASPxTextBox  acCode      = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcCode") as ASPxTextBox;
        ASPxComboBox acSource    = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcSource") as ASPxComboBox;
        ASPxTextBox  specialNote = this.ASPxGridView1.FindEditFormTemplateControl("txt_SpecialNote") 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;

        string invN = docN.Text;

        C2.XAArInvoice inv = Manager.ORManager.GetObject(typeof(XAArInvoice), SafeValue.SafeInt(invNCtr.Text, 0)) as XAArInvoice;
        if (inv == null)// first insert invoice
        {
            string counterType = "AR-IV";
            if (docType.Value.ToString() == "DN")
            {
                counterType = "AR-DN";
            }

            inv         = new XAArInvoice();
            invN        = C2Setup.GetNextNo("", counterType, docDate.Date);
            inv.PartyTo = SafeValue.SafeString(partyTo.Value, "");
            inv.DocType = docType.Value.ToString();
            inv.DocNo   = invN.ToString();
            inv.DocDate = docDate.Date;
            string[] currentPeriod = EzshipHelper.GetAccPeriod(docDate.Date);

            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], docDate.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], docDate.Date.Month);

            //
            int dueDay = SafeValue.SafeInt(termId.Text.ToUpper().Replace("DAYS", "").Trim(), 0);
            inv.DocDueDate  = inv.DocDate.AddDays(dueDay);//SafeValue.SafeDate(dueDt.Text, DateTime.Now);
            inv.Description = remarks1.Text;
            inv.CurrencyId  = docCurr.Text.ToString();
            inv.ExRate      = SafeValue.SafeDecimal(exRate.Value, 1);
            if (inv.ExRate <= 0)
            {
                inv.ExRate = 1;
            }
            inv.AcCode = EzshipHelper.GetAccArCode(inv.PartyTo, inv.CurrencyId);
            if (inv.AcCode == "")
            {
                throw new Exception("Please frist set account code!");
            }
            inv.AcSource    = acSource.Value.ToString();
            inv.SpecialNote = specialNote.Text;

            inv.MastType  = jobType.Text;
            inv.MastRefNo = mastRefNCtr.Text;
            inv.JobRefNo  = jobRefNCtr.Text;

            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);
            }
            catch
            {
            }
        }
        else
        {
            inv.PartyTo = SafeValue.SafeString(partyTo.Value, "");

            inv.Term    = termId.Text;
            inv.DocDate = docDate.Date;
            string[] currentPeriod = EzshipHelper.GetAccPeriod(docDate.Date);

            inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], docDate.Date.Year);
            inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], docDate.Date.Month);

            int dueDay = SafeValue.SafeInt(termId.Text.ToUpper().Replace("DAYS", "").Trim(), 0);
            inv.DocDueDate  = inv.DocDate.AddDays(dueDay);//SafeValue.SafeDate(dueDt.Text, DateTime.Now);
            inv.Description = remarks1.Text;
            inv.CurrencyId  = docCurr.Text.ToString();
            inv.ExRate      = SafeValue.SafeDecimal(exRate.Value, 1);
            if (inv.ExRate <= 0)
            {
                inv.ExRate = 1;
            }
            inv.AcCode      = EzshipHelper.GetAccArCode(inv.PartyTo, inv.CurrencyId);
            inv.AcSource    = acSource.Text;
            inv.SpecialNote = specialNote.Text;

            inv.MastType  = jobType.Text;
            inv.MastRefNo = mastRefNCtr.Text;
            inv.JobRefNo  = jobRefNCtr.Text;
            try
            {
                Manager.ORManager.StartTracking(inv, InitialState.Updated);
                Manager.ORManager.PersistChanges(inv);
                UpdateMaster(inv.SequenceId);
            }
            catch
            {
            }
        }
        Session["SeaIvEditWhere"]         = "SequenceId=" + inv.SequenceId;
        this.dsArInvoice.FilterExpression = Session["SeaIvEditWhere"].ToString();
        if (this.ASPxGridView1.GetRow(0) != null)
        {
            this.ASPxGridView1.StartEdit(0);
        }
    }
Ejemplo n.º 28
0
    public void ImportExcel(string batch, string file, out string error_text)
    {
        Aspose.Cells.License license = new Aspose.Cells.License();
        license.SetLicense(MapPath("~/Aspose.lic"));
        Workbook wb = new Workbook();

        if (file.ToLower().EndsWith(".csv"))
        {
            wb.Open(file, FileFormatType.CSV);
        }
        else
        {
            wb.Open(file);
        }
        int       empty_i = 0;
        string    re_text = "";
        Worksheet ws      = wb.Worksheets[0];

        int existDo     = 0;
        int successJob  = 0;
        int successItem = 0;
        int errorDo     = 0;


        //=================================== version 1
        bool beginImport = false;
        //int existDo = 0;
        //int successJob = 0;
        int  SortIndex = 0;
        bool action    = false;

        //Job Info
        string client      = ws.Cells["B" + 2].StringValue;
        string vessel      = ws.Cells["B" + 3].StringValue;
        string voyage      = ws.Cells["D" + 3].StringValue;
        string pol         = ws.Cells["B" + 4].StringValue;
        string pod         = ws.Cells["D" + 4].StringValue;
        string warehouse   = ws.Cells["H" + 2].StringValue;
        string isWarehouse = ws.Cells["J" + 2].StringValue;

        DateTime now   = DateTime.Now;
        string   jobNo = "";

        C2.CtmJob job = new C2.CtmJob();
        jobNo             = C2Setup.GetNextNo("", "CTM_Job_WGR", DateTime.Now);
        job.JobNo         = jobNo;
        job.JobType       = "WGR";
        job.JobDate       = DateTime.Now;
        job.ClientId      = EzshipHelper.GetPartyId(client);
        job.DeliveryTo    = "";
        job.StatusCode    = "USE";
        job.QuoteNo       = jobNo;
        job.QuoteStatus   = "None";
        job.JobStatus     = "Confirmed";
        job.Vessel        = vessel;
        job.Voyage        = voyage;
        job.Pol           = pol;
        job.Pod           = pod;
        job.WareHouseCode = warehouse;
        job.IsWarehouse   = isWarehouse;
        C2.Manager.ORManager.StartTracking(job, Wilson.ORMapper.InitialState.Inserted);
        C2.Manager.ORManager.PersistChanges(job);
        C2Setup.SetNextNo("", "CTM_Job_WGR", jobNo, now);

        auto_add_trailer_trip(jobNo, "WGR");

        //Order Info

        string bkgRefNo    = ws.Cells["B" + 7].StringValue;
        string hblNo       = ws.Cells["F" + 7].StringValue;
        string conNo       = ws.Cells["I" + 7].StringValue;
        string shipper     = ws.Cells["B" + 8].StringValue;
        string consignee   = ws.Cells["B" + 9].StringValue;
        string ic_uen      = ws.Cells["H" + 9].StringValue;
        string responsible = ws.Cells["K" + 9].StringValue;
        string email1      = ws.Cells["C" + 10].StringValue;
        string email2      = ws.Cells["H" + 10].StringValue;
        string tel         = ws.Cells["C" + 11].StringValue;
        string postCode    = ws.Cells["E" + 11].StringValue;
        string mobile      = ws.Cells["H" + 11].StringValue;
        string address     = ws.Cells["B" + 12].StringValue;
        string receiver    = ws.Cells["B" + 14].StringValue;
        string contact     = ws.Cells["B" + 15].StringValue;
        string delivery    = ws.Cells["B" + 16].StringValue;

        string  prepaidInd     = ws.Cells["C" + 18].StringValue;
        decimal collectAmount1 = SafeValue.SafeDecimal(ws.Cells["H" + 18].StringValue);
        decimal collectAmount2 = SafeValue.SafeDecimal(ws.Cells["K" + 18].StringValue);
        string  dutyPayment    = ws.Cells["B" + 19].StringValue;
        string  incoterm       = ws.Cells["B" + 20].StringValue;
        decimal ocean_freight  = SafeValue.SafeDecimal(ws.Cells["H" + 20].StringValue);
        string  remark         = ws.Cells["B" + 21].StringValue;

        string fee1CurrId = ws.Cells["H" + 24].StringValue;
        string totalQty   = ws.Cells["B" + 24].StringValue;
        string packType   = ws.Cells["D" + 2].StringValue;
        string weight     = ws.Cells["F" + 24].StringValue;
        string m3         = ws.Cells["J" + 24].StringValue;



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

        ConnectSql_mb.cmdParameters cpar = null;
        #region list add
        cpar = new ConnectSql_mb.cmdParameters("@BookingNo", bkgRefNo, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@HblNo", hblNo, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@JobNo", jobNo, SqlDbType.NVarChar);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@RefNo", jobNo, SqlDbType.NVarChar);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ContNo", conNo, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ShipperInfo", EzshipHelper.GetPartyId(shipper), SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ConsigneeInfo", consignee, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        if (responsible == "个人")
        {
            cpar = new ConnectSql_mb.cmdParameters("@Responsible", "PERSON", SqlDbType.NVarChar, 100);
            list.Add(cpar);
        }
        else
        {
            cpar = new ConnectSql_mb.cmdParameters("@Responsible", "COMPANY", SqlDbType.NVarChar, 100);
            list.Add(cpar);
        }
        cpar = new ConnectSql_mb.cmdParameters("@ConsigneeRemark", ic_uen, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        if (email2.Length > 0)
        {
            email1 += "," + email2;
        }
        cpar = new ConnectSql_mb.cmdParameters("@ConsigneeEmail", email1, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ConsigneeTel", tel, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ConsigneeZip", postCode, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@Mobile1", mobile, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ConsigneeAddress", address, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ClientId", receiver, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ClientEmail", contact, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@ClientAddress", delivery, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        string prepaid = "NO";
        if (prepaidInd.Equals("√"))
        {
            prepaid = "YES";
        }
        cpar = new ConnectSql_mb.cmdParameters("@PrepaidInd", prepaid, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@CollectAmount1", collectAmount1, SqlDbType.Decimal, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@CollectAmount2", collectAmount2, SqlDbType.Decimal, 100);
        list.Add(cpar);
        string payment = "";
        if (dutyPayment.Equals("税中国付/DUTY PAID"))
        {
            payment = "DUTY PAID";
        }
        else
        {
            payment = "DUTY UNPAID";
        }
        cpar = new ConnectSql_mb.cmdParameters("@DutyPayment", payment, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@Incoterm", incoterm, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@Ocean_Freight", ocean_freight, SqlDbType.Decimal, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@Remark1", remark, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@Currency", fee1CurrId, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@Qty", SafeValue.SafeDecimal(totalQty, 0), SqlDbType.Decimal, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@PackTypeOrig", packType, SqlDbType.NVarChar, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@Weight", SafeValue.SafeDecimal(weight, 0), SqlDbType.Decimal, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@Volume", SafeValue.SafeDecimal(m3, 0), SqlDbType.Decimal, 100);
        list.Add(cpar);
        cpar = new ConnectSql_mb.cmdParameters("@JobType", "WGR", SqlDbType.NVarChar, 100);
        list.Add(cpar);
        #endregion

        string sql = string.Format(@"insert into job_house (BookingNo,HblNo,JobNo,RefNo,JobType,ContNo,CargoStatus,ShipperInfo,ConsigneeInfo,Responsible,ConsigneeRemark, 
ConsigneeEmail,ConsigneeTel,Mobile1,ConsigneeAddress,ClientId,ClientEmail,ClientAddress,Remark1,Prepaid_Ind,Collect_Amount1,Collect_Amount2,Duty_Payment,Incoterm,Ocean_Freight,Currency,Qty,PackTypeOrig,Weight,Volume,CargoType) 
values (@BookingNo,@HblNo,@JobNo,@RefNo,@JobType,@ContNo,'P',@ShipperInfo,@ConsigneeInfo,@Responsible,@ConsigneeRemark,@ConsigneeEmail,@ConsigneeTel,@Mobile1,@ConsigneeAddress,@ClientId,@ClientEmail,@ClientAddress,@Remark1,@PrepaidInd,@CollectAmount1,
@CollectAmount2,@DutyPayment,@Incoterm,@Ocean_Freight,@Currency,@Qty,@PackTypeOrig,@Weight,@Volume,'IN') select @@identity");
        ConnectSql_mb.sqlResult re = ConnectSql_mb.ExecuteScalar(sql, list);
        if (re.status)
        {
            string id = SafeValue.SafeString(re.context);

            sql = string.Format(@"update job_house set LineId={0} where Id={0}", id);
            ConnectSql_mb.ExecuteNonQuery(sql);

            //insert_cargo(SafeValue.SafeInt(id, 0));
            if (id.Length > 0)
            {
                action = true;
                for (int i = 25; true; i++)
                {
                    if (empty_i >= 10)
                    {
                        break;
                    }
                    DateTime date = DateTime.Today;


                    string A = ws.Cells["A" + i].StringValue;
                    string B = ws.Cells["B" + i].StringValue;
                    string C = ws.Cells["C" + i].StringValue;
                    if (A.Trim().ToUpper().Equals("序号"))
                    {
                        beginImport = true;
                        empty_i++;
                        i = i + 1;
                        continue;
                    }
                    try
                    {
                        SortIndex = SafeValue.SafeInt(ws.Cells["A" + i].StringValue, 0);
                    }
                    catch
                    {
                        empty_i++;
                        continue;
                    }
                    if (C.Length <= 0 && B.Length <= 0)
                    {
                        empty_i++;
                        continue;
                    }
                    //empty_i = 0;

                    if (beginImport)
                    {
                        #region



                        string D = ws.Cells["D" + i].StringValue;
                        string E = ws.Cells["E" + i].StringValue;
                        string F = ws.Cells["F" + i].StringValue;
                        string G = ws.Cells["G" + i].StringValue;
                        #endregion
                        //=====================检测是否存在Bill Number
                        string    billNo    = D;
                        string    billItem  = E;
                        string    sql_check = string.Format(@"select Marks1 from job_stock where OrderId={0} and SortIndex={1} and Marks1='{2}'", id, SortIndex, C);
                        DataTable dt_check  = ConnectSql.GetTab(sql_check);
                        if (dt_check.Rows.Count > 0)
                        {
                            existDo++;
                            continue;
                        }
                        else
                        {
                            sql_check = string.Format(@"select count(*) from job_stock where OrderId={0}", id);
                            int n = SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql_check), 0);
                            SortIndex = n + 1;
                        }
                        try
                        {
                            list = new List <ConnectSql_mb.cmdParameters>();
                            #region list add
                            cpar = new ConnectSql_mb.cmdParameters("@SortIndex", SortIndex, SqlDbType.Int, 100);
                            list.Add(cpar);
                            cpar = new ConnectSql_mb.cmdParameters("@B", B, SqlDbType.NVarChar, 100);
                            list.Add(cpar);
                            cpar = new ConnectSql_mb.cmdParameters("@C", C, SqlDbType.NVarChar, 100);
                            list.Add(cpar);
                            cpar = new ConnectSql_mb.cmdParameters("@D", D, SqlDbType.NVarChar, 100);
                            list.Add(cpar);
                            cpar = new ConnectSql_mb.cmdParameters("@E", SafeValue.SafeInt(E, 0), SqlDbType.Int);
                            list.Add(cpar);
                            cpar = new ConnectSql_mb.cmdParameters("@F", SafeValue.SafeDecimal(F, 0), SqlDbType.Decimal);
                            list.Add(cpar);
                            cpar = new ConnectSql_mb.cmdParameters("@G", SafeValue.SafeDecimal(G), SqlDbType.Decimal);
                            list.Add(cpar);
                            cpar = new ConnectSql_mb.cmdParameters("@OrderId", id, SqlDbType.Int, 100);
                            list.Add(cpar);
                            #endregion

                            sql = string.Format(@"insert into job_stock (SortIndex,Marks1,Marks2,Uom1,Qty2,Price1,Price2, 
OrderId) values (@SortIndex,@B,@C,@D,@E,@F,@G,@OrderId)");
                            re  = ConnectSql_mb.ExecuteNonQuery(sql, list);
                            if (re.status)
                            {
                                successJob++;
                                //action = true;
                            }
                            else
                            {
                                errorDo++;
                                //throw new Exception(re.context);
                            }
                        }
                        catch (Exception ex)
                        {
                            errorDo++;
                            //throw new Exception(ex.ToString());
                        }
                    }
                    else
                    {
                    }
                }
                if (action)
                {
                    //VilaParty(consignee, uen, ic, email1, email2, tel1, tel2, mobile1, mobile2, address, responsible);
                }
            }
        }
        re_text    = string.Format(@"添加了 {0} 条货物", successJob);
        re_text   += successItem > 0 ? string.Format(@" {0} 条记录.", successItem) : ".";
        re_text   += existDo > 0 ? string.Format(@" {0} 条已存在", existDo) : "";
        re_text   += errorDo > 0 ? string.Format(@" {0} 条错误", errorDo) : "";
        error_text = re_text;
    }
Ejemplo n.º 29
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") %>","/WareHouse/Job/DoOutEdit.aspx?no=<%# Eval("DoNo") %>",{title:"<%# Eval("DoNo") %>", fresh:false, external:true});'><%# Eval("DoNo") %></a>
            Response.Redirect("/opsAccount/ArInvoiceEdit.aspx?no=" + invNo);
        }
    }
Ejemplo n.º 30
0
    protected void ASPxGridView1_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
    {
        string s = e.Parameters;

        if (true)
        {
            #region save
            ASPxTextBox  oidCtr         = this.ASPxGridView1.FindEditFormTemplateControl("txt_Oid") as ASPxTextBox;
            ASPxComboBox partyTo        = this.ASPxGridView1.FindEditFormTemplateControl("cmb_PartyTo") as ASPxComboBox;
            ASPxTextBox  otherPartyName = this.ASPxGridView1.FindEditFormTemplateControl("txt_OtherPartyName") as ASPxTextBox;
            ASPxComboBox docType        = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType") as ASPxComboBox;
            ASPxComboBox docType1       = this.ASPxGridView1.FindEditFormTemplateControl("cbo_DocType1") as ASPxComboBox;

            ASPxTextBox  docN    = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocNo") as ASPxTextBox;
            ASPxDateEdit docDate = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocDt") as ASPxDateEdit;
            ASPxMemo     remark  = this.ASPxGridView1.FindEditFormTemplateControl("txt_Remarks1") as ASPxMemo;

            ASPxTextBox  docCurr = this.ASPxGridView1.FindEditFormTemplateControl("txt_Currency") as ASPxTextBox;
            ASPxSpinEdit exRate  = this.ASPxGridView1.FindEditFormTemplateControl("txt_DocExRate") as ASPxSpinEdit;
            ASPxTextBox  acCode  = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcCode") as ASPxTextBox;

            ASPxTextBox  bankName = this.ASPxGridView1.FindEditFormTemplateControl("txt_BankName") as ASPxTextBox;
            ASPxTextBox  acDorc   = this.ASPxGridView1.FindEditFormTemplateControl("txt_AcDorc") as ASPxTextBox;
            ASPxTextBox  chqNo    = this.ASPxGridView1.FindEditFormTemplateControl("txt_ChequeNo") as ASPxTextBox;
            ASPxDateEdit chqDt    = this.ASPxGridView1.FindEditFormTemplateControl("txt_ChqDt") as ASPxDateEdit;
            ASPxTextBox  pic      = this.ASPxGridView1.FindEditFormTemplateControl("txt_Pic") as ASPxTextBox;

            ASPxSpinEdit   docAmt = this.ASPxGridView1.FindEditFormTemplateControl("spin_DocAmt") as ASPxSpinEdit;
            C2.XAArReceipt inv    = Manager.ORManager.GetObject(typeof(XAArReceipt), SafeValue.SafeInt(oidCtr.Text, 0)) as XAArReceipt;
            if (null == inv)                                                       // first insert invoice
            {
                string invN = C2Setup.GetNextNo("RE", "AR-RECEIPT", docDate.Date); //C2Setup.GetNextNo("AR-RECEIPT");
                inv             = new C2.XAArReceipt();
                inv.PartyTo     = SafeValue.SafeString(partyTo.Value, "");
                inv.DocNo       = invN;
                inv.DocType     = docType.Value.ToString();
                inv.DocType1    = docType1.Value.ToString();
                inv.DocDate     = docDate.Date;
                inv.ChqDate     = chqDt.Date;
                inv.Remark      = remark.Text;
                inv.DocCurrency = docCurr.Text.ToString();
                inv.DocExRate   = SafeValue.SafeDecimal(exRate.Value, 1);
                if (inv.DocExRate <= 0)
                {
                    inv.DocExRate = 1;
                }
                inv.AcCode    = acCode.Text;
                inv.BankName  = bankName.Text;
                inv.ChqNo     = chqNo.Text;
                inv.ExportInd = "N";

                if (inv.DocType1.ToLower() == "refund")
                {
                    inv.AcSource = "CR";
                }
                else
                {
                    inv.AcSource = "DB";
                }

                inv.DocAmt         = SafeValue.SafeDecimal(docAmt.Value, 0);
                inv.LocAmt         = inv.DocAmt * inv.DocExRate;
                inv.CancelDate     = new DateTime(1900, 1, 1);
                inv.CancelInd      = "N";
                inv.BankRec        = "N";
                inv.BankDate       = new DateTime(1900, 1, 1);
                inv.OtherPartyName = otherPartyName.Text;
                string[] currentPeriod = EzshipHelper.GetAccPeriod(docDate.Date);
                inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], docDate.Date.Year);
                inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], docDate.Date.Month);
                inv.Pic      = pic.Text;
                try
                {
                    inv.GenerateInd    = "N";
                    inv.CreateBy       = HttpContext.Current.User.Identity.Name;
                    inv.CreateDateTime = DateTime.Now;
                    inv.UpdateBy       = HttpContext.Current.User.Identity.Name;
                    inv.UpdateDateTime = DateTime.Now;
                    inv.PostBy         = "";
                    inv.PostDateTime   = new DateTime(1900, 1, 1);
                    C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Inserted);
                    C2.Manager.ORManager.PersistChanges(inv);
                    //inv.DocNo = inv.SequenceId.ToString();
                    C2.Manager.ORManager.StartTracking(inv, Wilson.ORMapper.InitialState.Updated);
                    C2.Manager.ORManager.PersistChanges(inv);
                    C2Setup.SetNextNo("", "AR-RECEIPT", invN, inv.DocDate);
                    //C2Setup.SetNextNo("AR-RECEIPT", invN);
                }
                catch
                {
                }
            }
            else
            {
                inv.PartyTo     = SafeValue.SafeString(partyTo.Value, "");
                inv.DocDate     = docDate.Date;
                inv.ChqDate     = chqDt.Date;
                inv.Remark      = remark.Text;
                inv.DocCurrency = docCurr.Text.ToString();
                inv.DocExRate   = SafeValue.SafeDecimal(exRate.Value, 1);
                if (inv.DocExRate <= 0)
                {
                    inv.DocExRate = 1;
                }
                inv.AcCode   = acCode.Text;
                inv.BankName = bankName.Text;
                inv.ChqNo    = chqNo.Text;
                inv.DocAmt   = SafeValue.SafeDecimal(docAmt.Value, 0);
                inv.LocAmt   = inv.DocAmt * inv.DocExRate;
                string[] currentPeriod = EzshipHelper.GetAccPeriod(docDate.Date);
                inv.AcYear   = SafeValue.SafeInt(currentPeriod[1], docDate.Date.Year);
                inv.AcPeriod = SafeValue.SafeInt(currentPeriod[0], docDate.Date.Month);

                inv.OtherPartyName = otherPartyName.Text;
                inv.Pic            = pic.Text;
                try
                {
                    inv.UpdateBy       = HttpContext.Current.User.Identity.Name;
                    inv.UpdateDateTime = DateTime.Now;
                    Manager.ORManager.StartTracking(inv, InitialState.Updated);
                    Manager.ORManager.PersistChanges(inv);
                }
                catch
                { }
            }
            Session["RecEditWhere"]           = "SequenceId=" + inv.SequenceId;
            this.dsArReceipt.FilterExpression = Session["RecEditWhere"].ToString();
            if (this.ASPxGridView1.GetRow(0) != null)
            {
                this.ASPxGridView1.StartEdit(0);
            }
            #endregion
        }
    }