Exemple #1
0
    protected int TransferProduct(string sku, string lotNo, string des, string wh, int qty, string loc, string doNo, int tId, string toWh, string toLoc)
    {
        int pId = 0;

        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(WhTransfer), "Id='" + tId + "'");
        WhTransfer transfer   = C2.Manager.ORManager.GetObject(query) as WhTransfer;
        bool       action     = false;
        string     transferNo = "";

        if (transfer == null)
        {
            action     = true;
            transfer   = new WhTransfer();
            transferNo = C2Setup.GetNextNo("Transfer");
        }
        string userId = HttpContext.Current.User.Identity.Name;

        transfer.TransferNo    = transferNo;
        transfer.RequestPerson = userId;
        transfer.RequestDate   = DateTime.Now;
        transfer.TransferDate  = DateTime.Now;
        transfer.Pic           = "";
        transfer.ConfirmPerson = "";
        transfer.ConfirmDate   = DateTime.Now;
        transfer.StatusCode    = "CLS";
        if (action)
        {
            transfer.TransferNo     = transferNo;
            transfer.CreateBy       = HttpContext.Current.User.Identity.Name;
            transfer.CreateDateTime = DateTime.Now;
            C2Setup.SetNextNo("Transfer", transferNo);
            Manager.ORManager.StartTracking(transfer, Wilson.ORMapper.InitialState.Inserted);
            Manager.ORManager.PersistChanges(transfer);
            pId = transfer.Id;
        }
        int id = 0;

        Wilson.ORMapper.OPathQuery query1 = new Wilson.ORMapper.OPathQuery(typeof(WhTransferDet), "Id='" + id + "'");
        WhTransferDet det = C2.Manager.ORManager.GetObject(query1) as WhTransferDet;

        if (det == null)
        {
            det = new WhTransferDet();
        }
        det.TransferNo      = transferNo;
        det.Product         = sku;
        det.LotNo           = lotNo;
        det.Qty1            = qty;
        det.FromWarehouseId = wh;
        det.FromLocId       = loc;
        det.ToWarehouseId   = toWh;
        det.ToLocId         = toLoc;
        det.Des1            = des;
        det.CreateBy        = userId;
        det.CreateDateTime  = DateTime.Now;
        det.UpdateBy        = userId;
        det.UpdateDateTime  = DateTime.Now;
        Manager.ORManager.StartTracking(det, Wilson.ORMapper.InitialState.Inserted);
        Manager.ORManager.PersistChanges(det);
        id = det.Id;

        string 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 DoNo, 'OUT' as DoType,Product
 ,'{2}' as Qty1
 ,0 as Qty2
 ,0 as Qty3
 ,Price
,'{3}' as LotNo
, Uom1,Uom2,Uom3, Uom4
,QtyPackWhole,QtyWholeLoose,QtyLooseBase
,'{4}' as CreateBy,getdate() as CreateDateTime,'{4}' as UpdateBy,getdate() as UpdateDateTime
,Att1,Att2,Att3,Att4,Att5,Att6,'{5}' as Des1,'' as Packing,'{6}' as Location,'Delivered' as ProcessStatus
from wh_dodet2 det where DoType='IN' and DoNo='{0}' and Product='{1}' and LotNo='{3}' and Location='{6}' select @@identity", doNo, sku, qty, lotNo, EzshipHelper.GetUserName(), des, loc);
        int doOutId = SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0);

        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 DoNo, 'IN' as DoType,Product
 ,'{2}' as Qty1
 ,0 as Qty2
 ,0 as Qty3
 ,Price
,'{3}' as LotNo
, Uom1,Uom2,Uom3, Uom4
,QtyPackWhole,QtyWholeLoose,QtyLooseBase
,'{4}' as CreateBy,getdate() as CreateDateTime,'{4}' as UpdateBy,getdate() as UpdateDateTime
,Att1,Att2,Att3,Att4,Att5,Att6,'{5}' as Des1,'' as Packing,'{6}' as Location,'Delivered' as ProcessStatus
from wh_dodet2 det where DoType='IN' and DoNo='{0}' and Product='{1}' and LotNo='{3}' and Location='{7}' select @@identity", doNo, sku, qty, lotNo, EzshipHelper.GetUserName(), des, toLoc, wh);
        int doInId = SafeValue.SafeInt(ConnectSql.ExecuteScalar(sql), 0);


        sql = string.Format(@"update wh_TransferDet set DoInId='{1}',DoOutId='{2}' where Id={0}", id, doInId, doOutId);
        C2.Manager.ORManager.ExecuteCommand(sql);
        return(pId);
    }
Exemple #2
0
    protected void AddOrUpdate()
    {
        ASPxTextBox txt_pId = this.grid.FindEditFormTemplateControl("txt_Id") as ASPxTextBox;
        string      pId     = SafeValue.SafeString(txt_pId.Text, "");

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

        if (transfer == null)
        {
            action     = true;
            transfer   = new WhTransfer();
            transferNo = C2Setup.GetNextNo("Transfer");
        }

        ASPxTextBox txt_TransferNo = this.grid.FindEditFormTemplateControl("txt_TransferNo") as ASPxTextBox;

        transfer.TransferNo = txt_TransferNo.Text.Trim();
        ASPxTextBox txt_RequestPerson = this.grid.FindEditFormTemplateControl("txt_RequestPerson") as ASPxTextBox;

        transfer.RequestPerson = txt_RequestPerson.Text;
        ASPxDateEdit de_RequestDate = this.grid.FindEditFormTemplateControl("de_RequestDate") as ASPxDateEdit;

        transfer.RequestDate = de_RequestDate.Date;
        ASPxDateEdit de_TransferDate = this.grid.FindEditFormTemplateControl("de_TransferDate") as ASPxDateEdit;

        transfer.TransferDate = de_TransferDate.Date;
        //ASPxComboBox cbo_StatusCode =this.grid.FindEditFormTemplateControl("cbo_StatusCode") as ASPxComboBox;
        //transfer.StatusCode = cbo_StatusCode.Text;
        ASPxTextBox txt_Pic = this.grid.FindEditFormTemplateControl("txt_Pic") as ASPxTextBox;

        transfer.Pic = txt_Pic.Text;
        ASPxTextBox txt_ConfirmPerson = this.grid.FindEditFormTemplateControl("txt_ConfirmPerson") as ASPxTextBox;

        transfer.ConfirmPerson = txt_ConfirmPerson.Text;
        ASPxDateEdit de_ConfirmDate = this.grid.FindEditFormTemplateControl("de_ConfirmDate") as ASPxDateEdit;

        transfer.ConfirmDate = de_ConfirmDate.Date;
        ASPxTextBox txt_UomWhole = this.grid.FindEditFormTemplateControl("txt_UomWhole") as ASPxTextBox;

        ASPxButtonEdit txt_PartyId = this.grid.FindEditFormTemplateControl("txt_PartyId") as ASPxButtonEdit;

        transfer.PartyId = txt_PartyId.Text;
        ASPxTextBox txt_PartyName = this.grid.FindEditFormTemplateControl("txt_PartyName") as ASPxTextBox;

        transfer.PartyName = txt_PartyName.Text;

        if (action)
        {
            transfer.TransferNo     = transferNo;
            transfer.CreateBy       = HttpContext.Current.User.Identity.Name;
            transfer.CreateDateTime = DateTime.Now;
            C2Setup.SetNextNo("Transfer", transferNo);
            Manager.ORManager.StartTracking(transfer, Wilson.ORMapper.InitialState.Inserted);
            Manager.ORManager.PersistChanges(transfer);
            Session["NameWhere"]             = "TransferNo='" + transferNo + "'";
            this.dsTransfer.FilterExpression = Session["NameWhere"].ToString();
            if (this.grid.GetRow(0) != null)
            {
                this.grid.StartEdit(0);
            }
        }
        else
        {
            transfer.UpdateBy       = HttpContext.Current.User.Identity.Name;
            transfer.UpdateDateTime = DateTime.Now;
            Manager.ORManager.StartTracking(transfer, Wilson.ORMapper.InitialState.Updated);
            Manager.ORManager.PersistChanges(transfer);
        }
    }