Example #1
0
        /// <summary>
        /// 修改过期时间
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void krpbChange_Click(object sender, EventArgs e)
        {
            //判断是否空
            if (krptPhoneNo.Text.Trim().Equals("") && (!string.IsNullOrWhiteSpace(krpt2.Text) || !string.IsNullOrWhiteSpace(krpt0.Text) || !string.IsNullOrWhiteSpace(krpt1.Text)))
            {
                KryptonMessageBox.Show(this, Resources.GetRes().GetString("InputPhoneNoFirst"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                // 隐藏功能时先把必要的复制掉(比如语言)
                CopyForHide(krpt0, krpt1, krpt2, false, Ext.AllSame(printInfo.Msg0, printInfo.Msg1, printInfo.Msg2));


                printInfo.IsPrintBillAfterBuy      = krpcIsPrintAfterBuy.Checked;
                printInfo.IsPrintBillAfterCheckout = krpcIsPrintAfterCheckout.Checked;


                printInfo.Phone = GetValueOrNull(krptPhoneNo.Text);

                printInfo.Msg2 = GetValueOrNull(krpt2.Text);
                printInfo.Msg1 = GetValueOrNull(krpt1.Text);
                printInfo.Msg0 = GetValueOrNull(krpt0.Text);

                printInfo.PageHeight = int.Parse(krpcPageHeight.Text);

                this.ReturnValue = printInfo;

                this.DialogResult = DialogResult.OK;

                this.Close();
            }
        }
Example #2
0
        /// <summary>
        /// 保存新增或改动的数据
        /// </summary>
        private void Save()
        {
            if (null != krpdgList.SelectedRows[0])
            {
                //如果是插入
                if (krpdgList.SelectedRows[0].Cells["krpcmRequestId"].Value.ToString().Equals("-1"))
                {
                    Request model = new Request();
                    try
                    {
                        // 隐藏功能时先把必要的复制掉(比如语言)
                        Common.GetCommon().CopyForHide(krpdgList.SelectedRows[0].Cells["krpcmRequestName0"], krpdgList.SelectedRows[0].Cells["krpcmRequestName1"], krpdgList.SelectedRows[0].Cells["krpcmRequestName2"], true, false, krpcbMultipleLanguage.Checked);

                        model.RequestId    = long.Parse(krpdgList.SelectedRows[0].Cells["krpcmRequestId"].Value.ToString());
                        model.RequestName0 = krpdgList.SelectedRows[0].Cells["krpcmRequestName0"].Value.ToString().Trim();
                        model.RequestName1 = krpdgList.SelectedRows[0].Cells["krpcmRequestName1"].Value.ToString().Trim();
                        model.RequestName2 = krpdgList.SelectedRows[0].Cells["krpcmRequestName2"].Value.ToString().Trim();
                        model.Order        = long.Parse(krpdgList.SelectedRows[0].Cells["krpcmOrder"].Value.ToString());
                        model.IsEnable     = long.Parse(krpdgList.SelectedRows[0].Cells["krpcmIsEnable"].Value.ToString());


                        //判断空
                        if (string.IsNullOrWhiteSpace(model.RequestName0) || string.IsNullOrWhiteSpace(model.RequestName1) || string.IsNullOrWhiteSpace(model.RequestName2))
                        {
                            KryptonMessageBox.Show(this, Resources.GetRes().GetString("CompleteInput"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }

                        //判断是否已存在
                        if (Resources.GetRes().Requests.Where(x => (x.RequestName0.Equals(model.RequestName0, StringComparison.OrdinalIgnoreCase) || x.RequestName1.Equals(model.RequestName1, StringComparison.OrdinalIgnoreCase) || x.RequestName2.Equals(model.RequestName2, StringComparison.OrdinalIgnoreCase))).Count() > 0)
                        {
                            KryptonMessageBox.Show(this, string.Format(Resources.GetRes().GetString("PropertyExists"), Resources.GetRes().GetString("RequestName")), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                        {
                            KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }), false, Resources.GetRes().GetString("SaveFailt"));
                        return;
                    }

                    StartLoad(this, null);

                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            bool result = OperatesService.GetOperates().ServiceAddRequest(model);

                            this.BeginInvoke(new Action(() =>
                            {
                                if (result)
                                {
                                    krpdgList.SelectedRows[0].Cells["krpcmRequestId"].Value = model.RequestId;
                                    KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    krpdgList.SelectedRows[0].Cells["krpcmEdit"].Value = "";
                                    resultList.Insert(0, model);
                                    Resources.GetRes().Requests.Add(model);

                                    ReloadRequestTextbox();
                                }
                                else
                                {
                                    KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveFailt"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }));
                        }
                        catch (Exception ex)
                        {
                            this.BeginInvoke(new Action(() =>
                            {
                                ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                                {
                                    KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }), false, Resources.GetRes().GetString("SaveFailt"));
                            }));
                        }
                        StopLoad(this, null);
                    });
                }
                //如果是编辑
                else
                {
                    Request model = new Request();
                    try
                    {
                        model.RequestId = long.Parse(krpdgList.SelectedRows[0].Cells["krpcmRequestId"].Value.ToString());

                        model = Resources.GetRes().Requests.Where(x => x.RequestId == model.RequestId).FirstOrDefault().FastCopy();

                        // 隐藏功能时先把必要的复制掉(比如语言)
                        Common.GetCommon().CopyForHide(krpdgList.SelectedRows[0].Cells["krpcmRequestName0"], krpdgList.SelectedRows[0].Cells["krpcmRequestName1"], krpdgList.SelectedRows[0].Cells["krpcmRequestName2"], false, Ext.AllSame(model.RequestName0, model.RequestName1, model.RequestName2), krpcbMultipleLanguage.Checked);

                        model.RequestName0 = krpdgList.SelectedRows[0].Cells["krpcmRequestName0"].Value.ToString().Trim();
                        model.RequestName1 = krpdgList.SelectedRows[0].Cells["krpcmRequestName1"].Value.ToString().Trim();
                        model.RequestName2 = krpdgList.SelectedRows[0].Cells["krpcmRequestName2"].Value.ToString().Trim();
                        model.Order        = long.Parse(krpdgList.SelectedRows[0].Cells["krpcmOrder"].Value.ToString());
                        model.IsEnable     = long.Parse(krpdgList.SelectedRows[0].Cells["krpcmIsEnable"].Value.ToString());


                        //判断空
                        if (string.IsNullOrWhiteSpace(model.RequestName0) || string.IsNullOrWhiteSpace(model.RequestName1) || string.IsNullOrWhiteSpace(model.RequestName2))
                        {
                            KryptonMessageBox.Show(this, Resources.GetRes().GetString("CompleteInput"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }

                        //判断是否已存在
                        if (Resources.GetRes().Requests.Where(x => x.RequestId != model.RequestId && (x.RequestName0.Equals(model.RequestName0, StringComparison.OrdinalIgnoreCase) || x.RequestName1.Equals(model.RequestName1, StringComparison.OrdinalIgnoreCase) || x.RequestName2.Equals(model.RequestName2, StringComparison.OrdinalIgnoreCase))).Count() > 0)
                        {
                            KryptonMessageBox.Show(this, string.Format(Resources.GetRes().GetString("PropertyExists"), Resources.GetRes().GetString("RequestName")), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                        {
                            KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }), false, Resources.GetRes().GetString("SaveFailt"));
                        return;
                    }

                    StartLoad(this, null);

                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            ResultModel result = OperatesService.GetOperates().ServiceEditRequest(model);

                            this.BeginInvoke(new Action(() =>
                            {
                                if (result.Result)
                                {
                                    KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveSuccess"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    krpdgList.SelectedRows[0].Cells["krpcmEdit"].Value = "";
                                    Request oldModel = resultList.Where(x => x.RequestId == model.RequestId).FirstOrDefault();

                                    int no = resultList.IndexOf(oldModel);
                                    resultList.RemoveAt(no);
                                    resultList.Insert(no, model);

                                    no = Resources.GetRes().Requests.IndexOf(oldModel);
                                    Resources.GetRes().Requests.RemoveAt(no);
                                    Resources.GetRes().Requests.Insert(no, model);

                                    ReloadRequestTextbox();
                                }
                                else
                                {
                                    if (result.UpdateModel)
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("PropertyUnSame"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                    else
                                    {
                                        KryptonMessageBox.Show(this, Resources.GetRes().GetString("SaveFailt"), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                }
                            }));
                        }
                        catch (Exception ex)
                        {
                            this.BeginInvoke(new Action(() =>
                            {
                                ExceptionPro.ExpLog(ex, new Action <string>((message) =>
                                {
                                    KryptonMessageBox.Show(this, message, Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }), false, Resources.GetRes().GetString("SaveFailt"));
                            }));
                        }
                        StopLoad(this, null);
                    });
                }
            }
        }