コード例 #1
0
ファイル: process_dzd_dzfz.cs プロジェクト: daniushou/mERP-CD
        public static void 自动填备注(ArchiveOperationForm masterForm)
        {
            int successCount = 0, skipCount = 0;

            ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
                {
                    using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<业务费用>())
                    {
                        rep.BeginTransaction();
                        foreach (Xceed.Grid.DataRow row in masterForm.MasterGrid.GridControl.SelectedRows)
                        {
                            if (!row.Cells["状态"].Value.ToString().Contains("95")) // 只有“未对账”的费用才会自动填备注
                            {
                                if (MessageForm.ShowYesNo("第 " + row.Cells["ID"].Value.ToString() + " 条不是未对账费用!" + Environment.NewLine
                                    + "提单号:" + row.Cells["提单号"].Value.ToString()
                                    + " 箱号:" + row.Cells["箱号"].Value.ToString()
                                    + " 费用项:" + row.Cells["费用项"].Value.ToString()
                                    + Environment.NewLine + "“是”跳过继续,“否”取消所有操作?", "提示"))
                                {
                                    skipCount++;
                                    continue;
                                }
                                else
                                {
                                    successCount = skipCount = 0;
                                    rep.RollbackTransaction();
                                    return null;
                                }
                            }

                            IList<业务费用> ywfy = (rep as Feng.NH.INHibernateRepository).List<业务费用>(NHibernate.Criterion.DetachedCriteria.For<业务费用>()
                                .Add(NHibernate.Criterion.Expression.Eq("车辆产值.ID", new Guid(row.Cells["车辆产值"].Value.ToString())))
                                .Add(NHibernate.Criterion.Expression.Eq("任务.ID", new Guid(row.Cells["任务"].Value.ToString())))
                                .Add(NHibernate.Criterion.Expression.Eq("费用项编号", row.Cells["费用项"].Value.ToString()))
                                .Add(NHibernate.Criterion.Expression.Eq("相关人编号", row.Cells["相关人"].Value.ToString()))
                                .Add(NHibernate.Criterion.Expression.Eq("金额", (decimal)row.Cells["金额"].Value)));

                            if (ywfy.Count > 1)
                            {
                                rep.RollbackTransaction();
                                throw new NullReferenceException("第 " + row.Cells["ID"].Value.ToString() + " 条对应了" + ywfy.Count + "条财务费用"
                                    + Environment.NewLine + "可能由于重复登记,请先查看删除多余记录");
                            }

                            ywfy[0].备注 += row.Cells["备注"].Value.ToString();
                            new 业务费用Dao().Update(rep, ywfy[0]);
                            successCount++;
                        }

                        rep.CommitTransaction();
                    }
                    return null;
                }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                    {
                        MessageForm.ShowInfo("成功" + successCount + "条, 跳过" + skipCount + "条");
                    }), masterForm, "执行");
        }
コード例 #2
0
        public static bool InternalExecuteWindowMenu(IDisplayManager dm, WindowMenuInfo info, Form parentForm)
        {
            object entity = dm.CurrentItem;
            int pos = dm.Position;
            //ArchiveOperationForm opForm = masterForm as ArchiveOperationForm;
            switch (info.Type)
            {
                case WindowMenuType.ReportSingle:
                    {
                        if (entity == null)
                        {
                            MessageForm.ShowError("请选择要打印的项!");
                            break;
                        }

                        ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                            new Feng.Async.AsyncHelper.DoWork(delegate()
                            {
                                MyReportForm form = new MyReportForm(info.ExecuteParam);
                                form.FillDataSet(entity);
                                return form;
                            }),
                            new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                            {
                                if (result != null)
                                {
                                    MyReportForm form = result as MyReportForm;
                                    form.Show(parentForm);
                                }
                            }),
                            parentForm, "生成");
                    }
                    break;
                case WindowMenuType.ReportMulti:
                    {
                        if (dm.Count == 0)
                        {
                            MessageForm.ShowError("请选择要打印的项!");
                            break;
                        }
                        object[] entities = new object[dm.Count];
                        for (int i = 0; i < entities.Length; ++i)
                        {
                            entities[i] = dm.Items[i];
                        }
                        ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                            new Feng.Async.AsyncHelper.DoWork(delegate()
                            {
                                MyReportForm form = new MyReportForm(info.ExecuteParam);
                                form.FillDataSet(entities);
                                return form;
                            }),
                            new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                            {
                                if (result != null)
                                {
                                    MyReportForm form = result as MyReportForm;
                                    form.Show(parentForm);
                                }
                            }),
                            parentForm, "生成");
                    }
                    break;
                case WindowMenuType.MsReportSingle:
                    {
                        if (entity == null)
                        {
                            MessageForm.ShowError("请选择要打印的项!");
                            break;
                        }

                        ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                            new Feng.Async.AsyncHelper.DoWork(delegate()
                            {
                                MsReportForm form = new MsReportForm(info.ExecuteParam);
                                form.FillDataSet(entity);
                                return form;
                            }),
                            new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                            {
                                if (result != null)
                                {
                                    MsReportForm form = result as MsReportForm;
                                    form.Show(parentForm);

                                    // 焦点会转变到其他程序,只能这样
                                    form.FormClosed += new FormClosedEventHandler(delegate(object sender, FormClosedEventArgs e)
                                    {
                                        parentForm.ParentForm.Activate();
                                    });
                                }
                            }),
                            parentForm, "生成");
                    }
                    break;
                case WindowMenuType.MsReportMulti:
                    {
                        if (dm.Count == 0)
                        {
                            MessageForm.ShowError("请选择要打印的项!");
                            break;
                        }
                        object[] entities = new object[dm.Count];
                        for (int i = 0; i < entities.Length; ++i)
                        {
                            entities[i] = dm.Items[i];
                        }

                        ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                            new Feng.Async.AsyncHelper.DoWork(delegate()
                            {
                                MsReportForm form = new MsReportForm(info.ExecuteParam);
                                form.FillDataSet(entities);
                                return form;
                            }),
                            new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                            {
                                if (result != null)
                                {
                                    MsReportForm form = result as MsReportForm;
                                    form.Show(parentForm);

                                    form.FormClosed += new FormClosedEventHandler(delegate(object sender, FormClosedEventArgs e)
                                    {
                                        parentForm.ParentForm.Activate();
                                    });
                                }

                            }),
                            parentForm, "生成");
                    }
                    break;
                case WindowMenuType.DatabaseCommand:
                    {
                        ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                            new Feng.Async.AsyncHelper.DoWork(delegate()
                            {
                                Feng.Data.DbHelper.Instance.ExecuteNonQuery(info.ExecuteParam);
                                return null;
                            }),
                            new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                            {
                            }),
                            parentForm, "执行");
                    }
                    break;
                case WindowMenuType.DatabaseCommandMulti:
                    {
                        StringBuilder sb = new StringBuilder();
                        for (int i = 0; i < dm.Count; ++i)
                        {
                            string s = EntityHelper.ReplaceEntity(info.ExecuteParam, dm.Items[i]);
                            sb.Append(s);
                            sb.Append(System.Environment.NewLine);
                        }
                        ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                            new Feng.Async.AsyncHelper.DoWork(delegate()
                            {
                                Feng.Data.DbHelper.Instance.ExecuteNonQuery(sb.ToString());
                                return null;
                            }),
                            new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                            {
                            }),
                            parentForm, "执行");
                    }
                    break;
                case WindowMenuType.DatabaseCommandMultiParam:
                    {
                        object[] entities = new object[dm.Count];
                        for (int i = 0; i < dm.Count; ++i)
                        {
                            entities[i] = dm.Items[i];
                        }
                        string s = EntityHelper.ReplaceEntities(info.ExecuteParam, entities, '\'');

                        ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                            new Feng.Async.AsyncHelper.DoWork(delegate()
                            {
                                Feng.Data.DbHelper.Instance.ExecuteNonQuery(s);
                                return null;
                            }),
                            new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                            {
                            }),
                            parentForm, "执行");

                    }
                    break;
                case WindowMenuType.Process:
                    {
                        ProcessInfoHelper.ExecuteProcess(info.ExecuteParam, new Dictionary<string, object> { { "masterForm", parentForm } });
                    }
                    break;
                case WindowMenuType.Action:
                    {
                        ServiceProvider.GetService<IApplication>().ExecuteAction(info.ExecuteParam);
                    }
                    break;
                default:
                    return false;
            }
            return true;
        }
コード例 #3
0
        public static void 载入出口报关单数据(ArchiveOperationForm masterForm)
        {
            GeneratedArchiveDataControlForm dataControlForm = ServiceProvider.GetService<IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("出口_备案_报关单导入")) as GeneratedArchiveDataControlForm;

            if (dataControlForm.ShowDialog() == DialogResult.OK)
            {
                if (dataControlForm.DataControls["委托时间"].SelectedDataValue == null)
                {
                    ServiceProvider.GetService<IMessageBox>().ShowWarning("请输入委托时间!");
                    return;
                }

                if (DateTime.Parse(dataControlForm.DataControls["委托时间"].SelectedDataValue.ToString()) > DateTime.Today)
                {
                    ServiceProvider.GetService<IMessageBox>().ShowWarning("不能载入大于今天的报关单数据!");
                    return;
                }

                DateTime wtsj = DateTime.Parse(dataControlForm.DataControls["委托时间"].SelectedDataValue.ToString());

                int count = 0;
                ProgressAsyncHelper pah = new ProgressAsyncHelper(new Feng.Async.AsyncHelper.DoWork(
                    delegate()
                    {
                        foreach (KeyValuePair<string, string> id in Get_nbediRead_ID())
                        {
                            m_nbediRead = new nbediRead();
                            m_nbediRead.SetLoginInfo(id.Key, id.Value);

                            //List<string> bgdhList = m_nbediRead.查询报关单号(wtsj);
                            Dictionary<string, string> bgdhList = m_nbediRead.查询报关单号2(wtsj);

                            if (bgdhList == null || bgdhList.Count == 0)
                            {
                                continue;
                            }

                            // 查询数据库已有提单号,避免重复数据
                            using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<出口票>())
                            {
                                try
                                {
                                    //IList<string> bgdh_List = (rep as Feng.NH.INHibernateRepository).Session.CreateCriteria(typeof(出口票))
                                    //    .SetProjection(NHibernate.Criterion.Projections.Distinct(NHibernate.Criterion.Projections.ProjectionList()
                                    //    .Add(NHibernate.Criterion.Projections.Property("报关单号")))).List<string>();

                                    //bool is查验 = true; // 海关查验是否正常,异常将不查询查验结果

                                    //foreach (string bgdh in bgdhList)   // 网上的报关单号
                                    //{
                                    foreach (KeyValuePair<string, string> bgdh in bgdhList)
                                    {
                                        if (bgdh.Key.Substring(9, 1) == "0" || bgdh.Key.Substring(9, 1) == "1")    // 0 = 进口,5 = 出口
                                        {
                                            continue;
                                        }

                                        IList<出口票> ckp_List = (rep as Feng.NH.INHibernateRepository).Session.CreateCriteria(typeof(出口票))
                                            .Add(NHibernate.Criterion.Expression.Eq("报关单号", bgdh.Key)).List<出口票>();

                                        if (ckp_List != null && ckp_List.Count > 0)
                                        {
                                            continue;
                                        }

                                        rep.BeginTransaction();

                                        报关单数据 bgdsj = m_nbediRead.查询报关单数据2(bgdh.Key, bgdh.Value);
                                        if (bgdsj != null)
                                        {
                                            出口票 ckp = new 出口票
                                            {
                                                报关单号 = bgdsj.报关单长号,
                                                抬头 = bgdsj.经营单位,
                                                提单号 = bgdsj.提运单号,
                                                核销单号 = bgdsj.批准文号,
                                                通关单号 = bgdsj.通关单号,
                                                //箱号 = bgdsj.箱号,// Formula = Distinct 出口箱.箱号
                                                箱量 = bgdsj.箱量,
                                                委托时间 = bgdsj.申报日期,
                                                船名航次 = bgdsj.船名航次,
                                                //报关单快照 = bgdsj.网页快照,
                                                报关员编号 = bgdsj.报关员,
                                                报关公司 = bgdsj.报关公司
                                            };

                                            if (!string.IsNullOrEmpty(ckp.提单号))
                                            {
                                                IList<集装箱数据> jzxList = null;
                                                try
                                                {
                                                    jzxList = m_nbediRead.查询集装箱数据(bgdsj.提运单号.Trim(), bgdsj.船名航次.Split('/')[0], bgdsj.船名航次.Split('/')[1]);
                                                    //IList<集装箱数据> jzxList = 查询出口集装箱数据By提单号航次(bgdsj.提运单号.Trim(), bgdsj.船名航次.Split('/')[1]);
                                                }
                                                catch
                                                {
                                                }

                                                if (jzxList != null && jzxList.Count > 0)
                                                {
                                                    List<string> success箱号 = new List<string>();

                                                    foreach (集装箱数据 jzx in jzxList)
                                                    {
                                                        // 避免重复箱保存
                                                        bool isSame箱号 = false;
                                                        foreach (string 箱号 in success箱号)
                                                        {
                                                            if (jzx.集装箱号 == 箱号)
                                                            {
                                                                isSame箱号 = true;
                                                                break;
                                                            }
                                                        }

                                                        if (isSame箱号)
                                                        {
                                                            continue;
                                                        }

                                                        int xx = 0;
                                                        if (int.TryParse(jzx.箱型, out xx))
                                                        {
                                                            if (xx < 40)
                                                            {
                                                                xx = 20;
                                                            }

                                                            if (xx >= 45)
                                                            {
                                                                xx = 41;
                                                            }
                                                            else
                                                            {
                                                                xx = 40;
                                                            }
                                                        }

                                                        int? 箱型编号 = null;
                                                        if (xx != 0)
                                                        {
                                                            箱型编号 = xx;
                                                        }

                                                        出口箱 newCkx = new 出口箱
                                                        {
                                                            箱号 = jzx.集装箱号,
                                                            箱型编号 = 箱型编号,
                                                            装货地编号 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", jzx.堆场区),
                                                            进港时间 = jzx.Real进场时间,
                                                            //提箱时间 = jzx.Real提箱时间
                                                        };

                                                        //if (is查验)
                                                        //{
                                                        //    try
                                                        //    {
                                                        //        查询海关查验结果(newCkx);
                                                        //    }
                                                        //    catch (Exception ex)
                                                        //    {
                                                        //        is查验 = false;
                                                        //        MessageForm.ShowError(ex.Message, "海关查验");
                                                        //    }
                                                        //}

                                                        success箱号.Add(newCkx.箱号);

                                                        if (ckp.进港地编号 == null && ckp.离港时间 == null)
                                                        {
                                                            ckp.进港地编号 = newCkx.装货地编号;
                                                            //ckp.离港时间 = newCkx.进港时间;

                                                            new 出口票Dao().Save(rep, ckp);

                                                            保存报关单快照(bgdsj.报关单长号, bgdsj.网页快照);
                                                        }

                                                        newCkx.票 = ckp;
                                                        new HdBaseDao<出口箱>().Save(rep, newCkx);
                                                    }
                                                }
                                                else
                                                {
                                                    new 出口票Dao().Save(rep, ckp);
                                                }
                                            }
                                        }
                                        rep.CommitTransaction();
                                        count++;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    rep.RollbackTransaction();
                                    throw new NullReferenceException(ex.Message, ex);
                                }
                            }
                        }
                        return null;
                    }), new Feng.Async.AsyncHelper.WorkDone(
                        delegate(object result)
                        {
                            MessageForm.ShowInfo("成功载入报关单数据" + count + "条");
                        }), masterForm, "载入报关单");
            }
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="doWork"></param>
        /// <param name="workDone"></param>
        public static AsyncHelper Start(AsyncHelper.DoWork doWork, AsyncHelper.WorkDone workDone, System.Windows.Forms.Form owner, string progressCaption)
        {
            var i = new ProgressAsyncHelper(doWork, workDone, owner, progressCaption);

            return(i.m_asyncHelper);
        }
コード例 #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="doWork"></param>
 /// <param name="workDone"></param>
 public static AsyncHelper Start(AsyncHelper.DoWork doWork, AsyncHelper.WorkDone workDone, System.Windows.Forms.Form owner, string progressCaption)
 {
     var i = new ProgressAsyncHelper(doWork, workDone, owner, progressCaption);
     return i.m_asyncHelper;
 }
コード例 #6
0
ファイル: process_dzd_dzfz.cs プロジェクト: daniushou/mERP-CD
        public static void 费用登记(ArchiveOperationForm masterForm)
        {
            int successCount = 0, skipCount = 0;

            ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
               new Feng.Async.AsyncHelper.DoWork(delegate()
               {
                   using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<业务费用>())
                   {
                       rep.BeginTransaction();

                       foreach (Xceed.Grid.DataRow row in masterForm.MasterGrid.GridControl.SelectedRows)
                       {
                           // 90 = 未备案
                           // 91 = 提单号不合理
                           // 92 = 箱号不合理
                           // 93 = 金额不同
                           // 94 = 已对账已凭证
                           // 95 = 未对账
                           // 96 = 未登记
                           // 97 = 未排车
                           // 98 = 费用不完整
                           if (!row.Cells["状态"].Value.ToString().Contains("96")) // 只有“未登记”的费用才会被登记
                           {
                               skipCount++;
                               continue;
                           }

                           if (row.Cells["相关人"].Value == null || row.Cells["费用项"].Value == null)
                           {
                               if (MessageForm.ShowYesNo("第 " + row.Cells["ID"].Value.ToString() + " 条费用,填写不完整!" + Environment.NewLine
                                   + "提单号:" + row.Cells["提单号"].Value.ToString()
                                   + " 箱号:" + row.Cells["箱号"].Value.ToString()
                                   + Environment.NewLine + "“是”跳过继续登记,“否”取消所有登记?", "提示"))
                               {
                                   skipCount++;
                                   continue;
                               }
                               else
                               {
                                   successCount = skipCount = 0;
                                   rep.RollbackTransaction();
                                   return null;
                               }
                           }

                           业务费用 ywfy = new 业务费用();
                           ywfy.相关人编号 = row.Cells["相关人"].Value.ToString();
                           ywfy.费用项编号 = row.Cells["费用项"].Value.ToString();
                           ywfy.金额 = Convert.ToDecimal(row.Cells["金额"].Value);
                           ywfy.收付标志 = 收付标志.付;
                           ywfy.费用归属 = 费用归属.委托人;
                           ywfy.车辆产值 = rep.Get<车辆产值>(new Guid(row.Cells["车辆产值"].Value.ToString()));
                           ywfy.任务 = rep.Get<任务>(new Guid(row.Cells["任务"].Value.ToString()));
                           ywfy.费用实体 = ywfy.车辆产值;

                           new 业务费用Dao().Save(rep, ywfy);
                           successCount++;
                           //rep.Save(ywfy);
                       }

                       rep.CommitTransaction();
                   }
                   return null;
               }),
                   new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                   {
                       MessageForm.ShowInfo("成功" + successCount + "条, 跳过" + skipCount + "条");
                   }), masterForm, "登记");
        }