Exemple #1
0
        protected void cmdAdd_ServerClick(object sender, System.EventArgs e)
        {
            Common.Domain.IDomainDataProvider erpDataProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider(DBName.ERP);

            FacadeFactory   facadeFactory = new FacadeFactory(base.DataProvider);
            InventoryFacade mesFac        = facadeFactory.CreateInventoryFacade();

            ((SQLDomainDataProvider)erpDataProvider).PersistBroker.OpenConnection();
            erpDataProvider.BeginTransaction();
            ((SQLDomainDataProvider)base.DataProvider).PersistBroker.OpenConnection();
            DataProvider.BeginTransaction();
            int iSelectedRowCount = 0;

            try
            {
                foreach (Infragistics.WebUI.UltraWebGrid.UltraGridRow row in this.gridWebGrid.Rows)
                {
                    if (row.Selected == true)
                    {
                        iSelectedRowCount++;
                        string factory = "PO";
                        if (System.Configuration.ConfigurationSettings.AppSettings["InvFactory"] != null)
                        {
                            factory = System.Configuration.ConfigurationSettings.AppSettings["InvFactory"].Trim();
                        }

                        if (row.Cells[7].Text.Trim() != languageComponent1.GetString(Web.Helper.INVERPType.INVERPTYPE_NEW))
                        {
                            ERPSRMX srmx = new ERPSRMX();
                            srmx.SRMXNO = mesFac.GetMaxSRNO(int.Parse(DateTime.Now.Year.ToString().Substring(2, 2)), factory);

                            srmx.ENDATE = FormatHelper.TODateInt(DateTime.Now);
                            string mocode = row.Cells[3].Text.Trim().Substring(5, row.Cells[3].Text.Trim().Length - 5);
                            srmx.SONO   = Convert.ToInt32(mocode);
                            srmx.FINQTY = Convert.ToDecimal(row.Cells[6].Text.Trim());
                            srmx.SRPROD = row.Cells[2].Text.Trim();
                            srmx.SRDESC = row.Cells[2].Text.Trim();
                            //srmx.
                            srmx.UID = GetUserCode();
                            srmx.STA = "F";

                            //向ERP中插入数据
                            erpDataProvider.Insert(srmx);

                            ERPINVInterface erp    = new  ERPINVInterface();
                            object          objERP = mesFac.GetERPINVInterface(
                                row.Cells[1].Text.Trim()
                                , row.Cells[3].Text.Trim()
                                , Web.Helper.INVERPType.INVERPTYPE_PROCESSED
                                , row.Cells[10].Text.Trim());

                            if (objERP != null)
                            {
                                erp = objERP as ERPINVInterface;
                            }
                            else
                            {
                                erp.RECNO    = row.Cells[1].Text.Trim();
                                erp.SRNO     = srmx.SRMXNO;
                                erp.ITEMCODE = row.Cells[2].Text.Trim();

                                erp.MDATE  = FormatHelper.TODateInt(row.Cells[4].Text.Trim());
                                erp.MOCODE = row.Cells[3].Text.Trim();
                                erp.MTIME  = FormatHelper.TOTimeInt(DateTime.Now);
                                erp.MUSER  = GetUserCode();
                                erp.QTY    = Decimal.Parse(row.Cells[6].Text.Trim());
                                erp.STATUS = Web.Helper.INVERPType.INVERPTYPE_PROCESSED;
//								erp.UPLOADDATE =  erp.MDATE;
//								erp.UPLOADTIME= erp.MTIME;
//								erp.UPLOADUSER =  erp.MUSER;
                            }

                            erp.UPLOADDATE = FormatHelper.TODateInt(DateTime.Now);
                            erp.UPLOADTIME = FormatHelper.TOTimeInt(DateTime.Now);
                            erp.UPLOADUSER = GetUserCode();;
                            erp.LINKSRNO   = row.Cells[10].Text.Trim();
                            erp.SRNO       = srmx.SRMXNO;

                            mesFac.AddERPINVInterface(erp);
                        }
                        else
                        {
                            ExceptionManager.Raise(typeof(ERPINVInterface), "状态必须为" + languageComponent1.GetString(Web.Helper.INVERPType.INVERPTYPE_PROCESSED));
                        }
                        erpDataProvider.CommitTransaction();
                        DataProvider.CommitTransaction();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Raise(this.GetType(), "", ex);
                erpDataProvider.RollbackTransaction();
            }
            finally
            {
                ((SQLDomainDataProvider)erpDataProvider).PersistBroker.CloseConnection();
                ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
            }

            if (iSelectedRowCount == 0)
            {
                ExceptionManager.Raise(typeof(ERPINVInterface), "没有选择任何记录");
            }
            else
            {
                this.Response.Redirect("FERPInvInterfaceQuery.aspx");
            }
        }
Exemple #2
0
        private void btnToss_Click(object sender, System.EventArgs e)
        {
            Common.Domain.IDomainDataProvider erpDataProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider(DBName.ERP);
            //ugrdREC.Selected


            ERPSRMX srmx = new ERPSRMX();

            string factory = "PO";

            if (System.Configuration.ConfigurationSettings.AppSettings["InvFactory"] != null)
            {
                factory = System.Configuration.ConfigurationSettings.AppSettings["InvFactory"].Trim();
            }


            InventoryFacade mesFac = new InventoryFacade(DataProvider);
            //Laws Lu,2006/11/13 uniform system collect date
            DBDateTime dbDateTime;

            dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);

            DateTime workDateTime = FormatHelper.ToDateTime(dbDateTime.DBDate, dbDateTime.DBTime);


            srmx.SRMXNO = mesFac.GetMaxSRNO(int.Parse(workDateTime.Year.ToString().Substring(2, 2)), factory);

            ArrayList arSRMX = new ArrayList();

//			foreach(Infragistics.Win.UltraWinGrid.UltraGridRow row in ugrdREC.Rows)
            for (int iGridRowLoopIndex = 0; iGridRowLoopIndex < ugrdREC.Rows.Count; iGridRowLoopIndex++)
            {
                Infragistics.Win.UltraWinGrid.UltraGridRow row = ugrdREC.Rows[iGridRowLoopIndex];
                if (row.Selected == true)
                {
                    DataProvider.BeginTransaction();
                    erpDataProvider.BeginTransaction();

                    try
                    {
                        srmx.ENDATE = FormatHelper.TODateInt(workDateTime);
                        string mocode = row.Cells["工单号"].Text.Trim().Substring(5, row.Cells["工单号"].Text.Trim().Length - 5);
                        srmx.SONO   = Convert.ToInt32(mocode);
                        srmx.FINQTY = Convert.ToDecimal(row.Cells["数量"].Text.Trim());
                        srmx.SRPROD = row.Cells["产品代码"].Text.Trim();
                        srmx.SRDESC = row.Cells["产品代码"].Text.Trim();
                        srmx.UID    = ApplicationService.Current().UserCode;
                        srmx.STA    = "F";


                        if (!arSRMX.Contains(srmx.SRMXNO + srmx.SONO))
                        {
                            arSRMX.Add(srmx.SRMXNO + srmx.SONO.ToString());
                            //向ERP中插入数据
                            erpDataProvider.Insert(srmx);
                        }
                        else
                        {
                            erpDataProvider.CustomExecute(new SQLCondition("UPDATE SRMX SET \"uid\" = '"
                                                                           + ApplicationService.Current().UserCode
                                                                           + "',FINQTY = FINQTY + "
                                                                           + Convert.ToDecimal(row.Cells["数量"].Text.Trim())
                                                                           + ",ENDATE = " + FormatHelper.TODateInt(workDateTime)
                                                                           + " WHERE SRMXNO = '" + srmx.SRMXNO + "' AND SONO = " + srmx.SONO));
                        }

                        object objErp = mesFac.GetERPINVInterface(
                            row.Cells["入库单号"].Text.Trim(),
                            row.Cells["工单号"].Text.Trim(),
                            Web.Helper.INVERPType.INVERPTYPE_NEW
                            , InventoryFacade.NewSRNO);

                        if (objErp != null)
                        {
                            ERPINVInterface erp = objErp as ERPINVInterface;
                            //更新系统数据
                            erp.SRNO       = srmx.SRMXNO;
                            erp.UPLOADUSER = ApplicationService.Current().UserCode;
                            erp.UPLOADDATE = FormatHelper.TODateInt(workDateTime);
                            erp.UPLOADTIME = FormatHelper.TOTimeInt(workDateTime);
                            erp.STATUS     = Web.Helper.INVERPType.INVERPTYPE_PROCESSED;
                            mesFac.UpdateERPINVInterfaceStatus(erp);
                        }

                        DataProvider.CommitTransaction();
                        erpDataProvider.CommitTransaction();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.Message);
                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(ex));

                        erpDataProvider.RollbackTransaction();
                        DataProvider.RollbackTransaction();
                    }
                    finally
                    {
                        ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                        ((SQLDomainDataProvider)erpDataProvider).PersistBroker.CloseConnection();
                    }
                }
            }
            ugrdREC_InitializeLayout(null, null);
            InitializeGrid();
            InitialForm();
        }