예제 #1
0
        /// <summary>
        /// 保存签证号
        /// </summary>
        void saveQZID()
        {
            try
            {
                this.MainBar.Focus();

                if (sendCollection.Count() == 0)
                {
                    MessageBox.Show("没有签证");
                    return;
                }

                foreach (var SendModel in sendCollection)
                {
                    if (string.IsNullOrEmpty(SendModel.FQZID))
                    {
                        if (QZIDnum == "" || QZIDstring == "")
                        {
                            MessageBox.Show("请先设置起始签证号码");
                            return;
                        }
                    }
                }

                string QZID = "";

                SendInfo sObj = new SendInfo();
                Customer cObj = new Customer();
                QZKC QZNOObj = new QZKC();

                int i = 0;
                if (!string.IsNullOrEmpty(QZIDnum))
                    i = Convert.ToInt32(QZIDnum);

                foreach (var SendModel in sendCollection)
                {
                    cObj = visaORM.Customer.FirstOrDefault(c => c.FID == SendModel.QID);
                    if (cObj != null)
                    {
                        if (string.IsNullOrEmpty(cObj.FQZID)) //如果没有签证号,就保存签证号
                        {

                            if (!string.IsNullOrEmpty(SendModel.FQZID))
                                QZID = SendModel.FQZID;
                            else
                                QZID = GetVisaNumberString(QZIDstring, i.ToString().Length, ref i);

                            QZNOObj = visaORM.QZKC.FirstOrDefault(q => q.FIsUse == false && q.FQZID == QZID);
                            if (QZNOObj == null)
                            {
                                MessageBox.Show(string.Format("签证号码{0}已经被使用或不存在,请添加或使用其他起始号码", QZID));
                                return;
                            }
                            cObj.FQZID = QZNOObj.FQZID;
                            QZNOObj.FIsUse = true;

                            sObj = visaORM.SendInfo.FirstOrDefault(s => s.FCustomerID == cObj.FID);

                            if (sObj != null) sObj.FQZID = QZNOObj.FQZID;

                            visaORM.ObjectStateManager.ChangeObjectState(sObj, System.Data.EntityState.Modified);
                            visaORM.ObjectStateManager.ChangeObjectState(cObj, System.Data.EntityState.Modified);
                            visaORM.ObjectStateManager.ChangeObjectState(QZNOObj, System.Data.EntityState.Modified);
                            visaORM.SaveChanges();
                            i++;
                        }
                        else //如果已有签证号,提示是否覆盖
                        {
                            if (
                                System.Windows.MessageBox.Show(
                                    string.Format("护照号为{0}已存在签证号(可能是上一次录入或者本次手动录入),是否覆盖当前号码?", SendModel.PID), "已存在签证号",
                                    MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                            {
                                //更新表一的签证号码
                                cObj.FQZID = SendModel.FQZID;

                                //更新签证号码表中的使用情况
                                QZNOObj = visaORM.QZKC.FirstOrDefault(q => q.FIsUse == false && q.FQZID == SendModel.FQZID);
                                if (QZNOObj == null)
                                {
                                    MessageBox.Show(string.Format("签证号码{0}已经被使用或不存在,请添加或使用其他起始号码", SendModel.FQZID));
                                    return;
                                }
                                cObj.FQZID = QZNOObj.FQZID;
                                QZNOObj.FIsUse = true;

                                //更新表三的签证号码
                                sObj = visaORM.SendInfo.FirstOrDefault(s => s.FCustomerID == cObj.FID);
                                if (sObj != null)
                                {
                                    sObj.FQZID = QZNOObj.FQZID;
                                    visaORM.ObjectStateManager.ChangeObjectState(sObj, System.Data.EntityState.Modified);
                                }
                                visaORM.ObjectStateManager.ChangeObjectState(cObj, System.Data.EntityState.Modified);
                                visaORM.ObjectStateManager.ChangeObjectState(QZNOObj, System.Data.EntityState.Modified);
                                visaORM.SaveChanges();
                            }
                        }

                    }

                }

                MessageBox.Show("保存成功");
                if (System.Windows.MessageBox.Show("保存签证成功,是否继续打印表四", "保存成功", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    printTable4();
                }
                //保存时设置为保存为已打印
                SaveSysPrint();
                //初始化未打印的名单列表
                InitNotPrintSource(false);
                sendCollection.Clear();
                cbNotPrint.EditValue = "";

            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.WriteLog.WriteErorrLog(ex);

            }
        }
예제 #2
0
 /// <summary>
 /// 创建新的 SendInfo 对象。
 /// </summary>
 /// <param name="fID">FID 属性的初始值。</param>
 /// <param name="fCustomerID">FCustomerID 属性的初始值。</param>
 public static SendInfo CreateSendInfo(global::System.Int32 fID, global::System.Int32 fCustomerID)
 {
     SendInfo sendInfo = new SendInfo();
     sendInfo.FID = fID;
     sendInfo.FCustomerID = fCustomerID;
     return sendInfo;
 }
예제 #3
0
 /// <summary>
 /// 用于向 SendInfo EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToSendInfo(SendInfo sendInfo)
 {
     base.AddObject("SendInfo", sendInfo);
 }
예제 #4
0
        /// <summary>
        /// 提交送审名单
        /// </summary>
        void SendList()
        {
            // var modelCollection = visaORM.Customer.Where(c => c.FSysPut == false);
            try
            {
                if (cbVietnamCompany.SelectedItem == null)
                {
                    MessageBox.Show("请先选择越南公司");
                    return;
                }

                string todayStringShort = DateTime.Now.ToString("yyMMdd");
                string todayStringAll = DateTime.Now.ToShortDateString();

                string selectietnamCompany = cbVietnamCompany.SelectedItem.ToString();

                int orderNum = 1;

                foreach (var model in Sendoc)
                {

                    var BlackListObj = visaORM.CustomerT.FirstOrDefault(c => c.FPassportNo == model.FPassportNo);
                    if (BlackListObj != null)
                    {
                        if (MessageBox.Show(string.Format("护照号{0}是特殊人物,是否让其提交?", model.FPassportNo), "特殊人物确认", MessageBoxButton.YesNo) == MessageBoxResult.No)
                        {
                            continue;
                        }
                    }

                    if (model.FSysSend == true)
                    {
                        MessageBox.Show(" 此签证已经送审过,不能再次送审:" + model.FPassportNo);
                        continue;
                    }

                    //visaORM.Customer.Attach(model);
                    Customer modelC = visaORM.Customer.FirstOrDefault(c => c.FID == model.FID);
                    if (modelC == null)
                    {
                        MessageBox.Show("该签证不存在或者已经被删除:" + model.FPassportNo);
                        continue;
                    }
                    visaORM.ObjectStateManager.ChangeObjectState(modelC, System.Data.EntityState.Modified);
                    modelC.FSysSend = true;
                    modelC.FSysSendDate = DateTime.Now;
                    modelC.FSysSendUser = MainContext.UserID;
                    modelC.FYNCom = selectietnamCompany;

                    var modelSend = new SendInfo();

                    modelSend.FCustomerID = model.FID;
                    modelSend.FQZID = model.FQZID;
                    modelSend.FSendDate = modelC.FSysSendDate;
                    modelSend.FDSN = txtDSN.Text;
                    modelSend.FVietnamCompany = selectietnamCompany;
                    modelSend.FCreateCompany = MainContext.UserCompanyName;
                    modelSend.FSendNo = modelSend.FDSN;
                    modelSend.FOrder = orderNum;
                    modelSend.FCDate = todayStringShort;
                    modelSend.FSysPrintNum = 0;

                    modelSend.FCreateDate = DateTime.Now;
                    modelSend.FCreateUser = MainContext.UserID;
                    modelSend.FModifyDate = DateTime.Now;
                    modelSend.FModifyUser = MainContext.UserID;
                    modelSend.FStatus = true;

                    modelSend.FSysSend = true;
                    modelSend.FSysSendDate = modelC.FSysSendDate;
                    modelSend.FSysSendUser = 1;

                    modelSend.FSysChk = false;
                    modelSend.FSysPrint = false;

                    visaORM.SendInfo.AddObject(modelSend);

                    orderNum++;
                }
                visaORM.SaveChanges();

                Sendoc.Clear();
                MessageBox.Show("送审成功");

                //重新初始化DSN下拉
                InitSendComboBox();
                this.sendNoString = txtDSN.Text;
                //cbListSend.SelectedItem = txtDSN.Text;
                //导出
                exportList();
                //((TableView)gridMain.View).Print();

                //越南公司清空
                this.cbVietnamCompany.SelectedIndex = -1;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.WriteLog.WriteErorrLog(ex);

            }
        }