Beispiel #1
0
        private void ParsePresentation(PresentationData presData)
        {
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork               += worker_DoWork;
            worker.RunWorkerCompleted   += worker_RunWorkerCompleted;
            worker.WorkerReportsProgress = true;
            worker.ProgressChanged      += worker_ProgressChanged;

            WorkerArgument workerArgument = new WorkerArgument
            {
                PresentationControl  = presData.PresentationControl,
                PresentationName     = presData.PresentationName,
                PresentationFullPath = presData.PresentationFullPath,
                //PresentationTitle = string.Empty,
                SelectedItem = presData.Category,
                //UrlNews = UrlNews.Text,
                Login = presData.Login
            };

            presData.PresentationControl.PresentationGrid.Opacity   = 0.2;
            presData.PresentationControl.PresentationGrid.IsEnabled = false;

            worker.RunWorkerAsync(workerArgument);
        }
Beispiel #2
0
        private void _worker_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerArgument       arg   = e.Argument as WorkerArgument;
            ICollection <string> words = new WordGenerator().GenerateWords(arg.Size, arg.Choices);

            string[] wordsArray = new string[words.Count];
            words.CopyTo(wordsArray, 0);
            e.Result = wordsArray;
        }
        private bool NewMethod(BackgroundWorker worker, DoWorkEventArgs e)
        {
            WorkerArgument arg = e.Argument as WorkerArgument;

            bool success = true;

            try
            {
                string sheetName = this.pathTextBox.Text;
                {
                    clsAllnew          BUINESS = new clsAllnew();
                    List <clsDATAinfo> dt      = BUINESS.Read_Excel(sheetName);


                    int rowCount = dt.Count;
                    arg.OrderCount = rowCount;
                    int i        = 0;
                    int progress = 0;
                    {
                        foreach (clsDATAinfo item in dt)
                        {
                            i               += 1;
                            progress         = Convert.ToInt16(((i) * 1.0 / rowCount) * 100);
                            arg.CurrentIndex = i;
                            item.xinzeng     = "true";
                            string conditions = "";
                            conditions = BUINESS.sql_yuju(e, item, conditions);
                            int isrun = BUINESS.update_Server(conditions, item);
                            item.xinzeng = "false";


                            backgroundWorker1.ReportProgress(progress, arg);
                        }
                    }
                    backgroundWorker1.ReportProgress(100, arg);
                    e.Result = string.Format("{0} 条正常导入成功", dt.Count);
                }
            }
            catch (Exception exception)
            {
                if (!e.Cancel)
                {
                    //arg.HasError = true;
                    //arg.ErrorMessage = exception.Message;
                    e.Result = exception.Message + "或所导入信息超出要求长度";
                }
                success = false;
            }

            return(success);
        }
        private void backgroundWorker2_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            WorkerArgument arg = e.UserState as WorkerArgument;

            if (!arg.HasError)
            {
                this.toolStripLabel1.Text = String.Format("{0}/{1}", arg.CurrentIndex, arg.OrderCount);
                this.ProgressValue        = e.ProgressPercentage;
            }
            else
            {
                this.toolStripLabel1.Text = arg.ErrorMessage;
            }
        }
Beispiel #5
0
        public MainViewModel()
        {
            RestartCommand = new UtilityWpf.RelayCommand(() => _itemsCount.OnNext(5));

            var dis = Application.Current.Dispatcher;
            var x   = new System.Reactive.Concurrency.DispatcherScheduler(dis);

            GetNewItems(_itemsCount).Switch().ObserveOn(x).Subscribe(_ =>
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    NewItem = _;
                    OnPropertyChanged(nameof(NewItem));
                });
            });

            RestartCommand.Execute(5);
        }
        private bool dailysaveList(BackgroundWorker worker, DoWorkEventArgs e)
        {
            WorkerArgument arg          = e.Argument as WorkerArgument;
            clsAllnew      BusinessHelp = new clsAllnew();
            bool           success      = true;

            try
            {
                int rowCount = changeindex.Count;
                arg.OrderCount = rowCount;
                int j        = 1;
                int progress = 0;
                #region MyRegion
                for (int ik = 0; ik < changeindex.Count; ik++)
                {
                    j = ik;

                    arg.CurrentIndex = j + 1;
                    progress         = Convert.ToInt16(((j + 1) * 1.0 / rowCount) * 100);

                    int i   = changeindex[ik];
                    var row = dataGridView1.Rows[i];

                    var model = row.DataBoundItem as cls_kehucishufashengshijian_info;

                    cls_kehucishufashengshijian_info item = new cls_kehucishufashengshijian_info();

                    item.kehuxingming = Convert.ToString(dataGridView1.Rows[i].Cells["kehuxingming"].EditedFormattedValue.ToString());

                    item.shangcichugongshijian = Convert.ToString(dataGridView1.Rows[i].Cells["shangcichugongshijian"].EditedFormattedValue.ToString());

                    item.shangcichugongbaojie = Convert.ToString(dataGridView1.Rows[i].Cells["shangcichugongbaojie"].EditedFormattedValue.ToString());

                    item.kehupingjia = Convert.ToString(dataGridView1.Rows[i].Cells["kehupingjia"].EditedFormattedValue.ToString());

                    item.beizhu = Convert.ToString(dataGridView1.Rows[i].Cells["beizhu"].EditedFormattedValue.ToString());

                    item.xinzeng    = Convert.ToString(dataGridView1.Rows[i].Cells["xinzeng"].EditedFormattedValue.ToString());
                    item.Input_Date = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));
                    item.status_id  = model.status_id;

                    #endregion

                    #region MyRegion


                    #region  构造查询条件
                    string conditions = "";
                    conditions = sql_yuju(e, item, conditions);

                    #endregion
                    #endregion

                    int isrun = BusinessHelp.updatecustomer_Server(conditions);
                    if (item.xinzeng == "true" && isrun == 1)
                    {
                        item.xinzeng = "";
                    }

                    if (arg.CurrentIndex % 5 == 0)
                    {
                        backgroundWorker2.ReportProgress(progress, arg);
                    }
                }
                backgroundWorker2.ReportProgress(100, arg);
                e.Result = string.Format("{0} 已保存 !", changeindex.Count);
            }
            catch (Exception ex)
            {
                if (!e.Cancel)
                {
                    e.Result = ex.Message + "";
                }
                success = false;
            }

            return(success);
        }
    private void ParsePresentation(PresentationData presData)
    {
      BackgroundWorker worker = new BackgroundWorker();
      worker.DoWork += worker_DoWork;
      worker.RunWorkerCompleted += worker_RunWorkerCompleted;
      worker.WorkerReportsProgress = true;
      worker.ProgressChanged += worker_ProgressChanged;

      WorkerArgument workerArgument = new WorkerArgument
      {
        PresentationControl = presData.PresentationControl,
        PresentationName = presData.PresentationName,
        PresentationFullPath = presData.PresentationFullPath,
        //PresentationTitle = string.Empty,
        SelectedItem = presData.Category,
        //UrlNews = UrlNews.Text,
        Login = presData.Login
      };

      presData.PresentationControl.PresentationGrid.Opacity = 0.2;
      presData.PresentationControl.PresentationGrid.IsEnabled = false;

      worker.RunWorkerAsync(workerArgument);
    }
Beispiel #8
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerArgument argument = (WorkerArgument)e.Argument;

            var progressStatus = new ParseProgressStatus {
                PresentationControl = argument.PresentationControl
            };

            MySQLPresentationTable abstractpresTable = null;
            PresentationInfo       presInfo          = null;

            try
            {
                #region Парсинг презентации

                ((BackgroundWorker)sender).ReportProgress(0,
                                                          new ParseProgressStatus
                {
                    PresentationControl = argument.PresentationControl,
                    Message             = "Начало парсинга презентации",
                    IsOnlyMessage       = true
                });


                using (PPTFiles pptFiles = new PPTFiles())
                {
                    #region Получаюданные настройки соединения с БД

                    string dbRemoteHost = null,
                           dbName       = null,
                           dbUser       = null,
                           dbPassword   = null;

                    try
                    {
                        XDocument xmlDBDoc = XDocument.Load("Lib\\FCashProfile.tss");

                        var XdbRemoteHost = xmlDBDoc.Root.Element(XName.Get("ExportDBInfo")).Element(XName.Get("DBRemoteHost"));
                        dbRemoteHost = XdbRemoteHost.Value;

                        var XdbName = xmlDBDoc.Root.Element(XName.Get("ExportDBInfo")).Element(XName.Get("DBName"));
                        dbName = XdbName.Value;

                        var XdbUser = xmlDBDoc.Root.Element(XName.Get("ExportDBInfo")).Element(XName.Get("DBUser"));
                        dbUser = XdbUser.Value;

                        var XdbPassword = xmlDBDoc.Root.Element(XName.Get("ExportDBInfo")).Element(XName.Get("DBPassword"));
                        dbPassword = XdbPassword.Value;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(
                                  String.Format("Не получилось получить конфигурационные данные из файла конфигурации: {0}", ex.Message));
                    }

                    //if (!String.IsNullOrEmpty(argument.UrlNews))
                    //    presInfo.UrlNews = argument.UrlNews;


                    if (String.IsNullOrEmpty(dbRemoteHost) || String.IsNullOrEmpty(dbName) || String.IsNullOrEmpty(dbUser))
                    {
                        throw new Exception(
                                  "У вас не заполнена конфигурация соединения с базой данных для экспорта\nПожалуйста заполните ее через настройки");
                    }

                    MySQLPresentationTable presTable = new MySQLPresentationTable(dbRemoteHost, dbName, dbUser, dbPassword);
                    abstractpresTable = presTable;

                    #endregion

                    pptFiles.ParseSlideCompleteCallback += (object pptFile, SlideCompleteParsingInfo slideParsingInfo) =>
                    {
                        ((BackgroundWorker)sender).ReportProgress(
                            (int)((decimal)slideParsingInfo.SlideCurrentNumber / (decimal)slideParsingInfo.SlideTotalNumber * 100),
                            new ParseProgressStatus
                        {
                            PresentationControl = argument.PresentationControl,
                            Message             = "Обработка слайдов"
                        });
                    };

                    presTable.CreateTable();

                    presInfo           = pptFiles.ExtractInfo(argument.PresentationFullPath, presTable);
                    presInfo.Name      = argument.PresentationName;
                    presInfo.Title     = argument.PresentationTitle;
                    presInfo.Login     = argument.Login;
                    presInfo.Categorie = ((KeyValuePair <string, string>)argument.SelectedItem);
                }

                #endregion

                #region Заливка информации по презентации в БД

                {
                    ((BackgroundWorker)sender).ReportProgress(0,
                                                              new ParseProgressStatus
                    {
                        PresentationControl = argument.PresentationControl,
                        Message             = "Обновление данных на сервере",
                        IsOnlyMessage       = true
                    });

                    abstractpresTable.PutDataOnServer(presInfo);
                }

                #endregion

                #region Отправка на FTP

                try
                {
                    ((BackgroundWorker)sender).ReportProgress(0,
                                                              new ParseProgressStatus
                    {
                        PresentationControl = argument.PresentationControl,
                        Message             = "Подготовка к отправке файлов на FTP",
                        IsOnlyMessage       = true
                    });

                    XDocument xmlFtpDoc = XDocument.Load("Lib\\FCashProfile.tss");

                    var ftpHost         = xmlFtpDoc.Root.Element(XName.Get("ExportFtpInfo")).Element(XName.Get("Host"));
                    var ftpUserName     = xmlFtpDoc.Root.Element(XName.Get("ExportFtpInfo")).Element(XName.Get("UserName"));
                    var ftpUserPassword = xmlFtpDoc.Root.Element(XName.Get("ExportFtpInfo")).Element(XName.Get("UserPassword"));
                    var ftpImagesDir    = xmlFtpDoc.Root.Element(XName.Get("ExportFtpInfo")).Element(XName.Get("ImagesDir"));

                    FTP ftp = new FTP(ftpHost.Value, ftpUserName.Value, ftpUserPassword.Value, ftpImagesDir.Value);
                    ftp.UploadImageCompleteCallback += (object ftpSender, UploadImageCompliteInfo completeInfo) =>
                    {
                        ((BackgroundWorker)sender).ReportProgress(
                            (int)((decimal)completeInfo.CurrentImageNumber / (decimal)completeInfo.TotalImagesCount * 100),
                            new ParseProgressStatus
                        {
                            PresentationControl = argument.PresentationControl,
                            Message             = "Загрузка изображений на FTP"
                        });
                    };

                    ftp.OnUploadPresentationBlockCallbak += (object ftpSender, UploadPresentationBlockInfo blockInfo) =>
                    {
                        ((BackgroundWorker)sender).ReportProgress(blockInfo.PercentProgress,
                                                                  new ParseProgressStatus
                        {
                            PresentationControl = argument.PresentationControl,
                            Message             = "Загрузка презентации"
                        });
                    };

                    List <string> imageNames = new List <string>();

                    foreach (var slideInfo in presInfo.SlidersInfo)
                    {
                        if (!String.IsNullOrEmpty(slideInfo.ImageNameClientSmall))
                        {
                            imageNames.Add(slideInfo.ImageNameClientSmall);
                        }

                        if (!String.IsNullOrEmpty(slideInfo.ImageNameClientAverage))
                        {
                            imageNames.Add(slideInfo.ImageNameClientAverage);
                        }

                        if (!String.IsNullOrEmpty(slideInfo.ImageNameClientBig))
                        {
                            imageNames.Add(slideInfo.ImageNameClientBig);
                        }
                    }

                    ftp.UploadImages(presInfo);
                }
                catch (Exception ex)
                {
                    throw new Exception(String.Format("Во время отправки изображений на FTP возникла ошибка: {0}", ex.Message));
                }

                #endregion
            }
            catch (Exception ex)
            {
                lock (_exceptionLoger)
                {
                    _exceptionLoger.WriteLog(string.Format(Environment.NewLine + Environment.NewLine + "[{0}] Во время обработки презентации [{1}] произошла ошибка.\r\n Ошибка: {2} \r\nСтек вызова: {3}", DateTime.Now, argument.PresentationName, ex.Message, ex.StackTrace));
                }

                // Удаляю пустую подготовленную строчку для презентации из таблицы
                if (presInfo != null)
                {
                    try
                    {
                        abstractpresTable.DeleteFromMainTable((ulong)presInfo.DbId);
                    }
                    catch (Exception ex2)
                    {
                        lock (_exceptionLoger)
                        {
                            _exceptionLoger.WriteLog(string.Format(Environment.NewLine + Environment.NewLine + "[{0}] Во время обработки презентации [{1}] произошла ошибка.\r\n Ошибка: {2} \r\nСтек вызова: {3}", DateTime.Now, argument.PresentationName, ex2.Message, ex2.StackTrace));
                        }
                    }
                }

                progressStatus.IsError = true;
            }
            finally
            {
                e.Result = progressStatus;
            }
        }
Beispiel #9
0
        private bool dailysaveList(BackgroundWorker worker, DoWorkEventArgs e)
        {
            WorkerArgument arg          = e.Argument as WorkerArgument;
            clsAllnew      BusinessHelp = new clsAllnew();
            bool           success      = true;

            try
            {
                int rowCount = changeindex.Count;
                arg.OrderCount = rowCount;
                int j        = 1;
                int progress = 0;
                #region MyRegion
                for (int ik = 0; ik < changeindex.Count; ik++)
                {
                    j = ik;

                    arg.CurrentIndex = j + 1;
                    progress         = Convert.ToInt16(((j + 1) * 1.0 / rowCount) * 100);

                    int i   = changeindex[ik];
                    var row = dataGridView1.Rows[i];

                    var model = row.DataBoundItem as clscustomerinfo;

                    clscustomerinfo item = new clscustomerinfo();

                    item.customer_name = Convert.ToString(dataGridView1.Rows[i].Cells["customer_name"].EditedFormattedValue.ToString());

                    item.customer_adress = Convert.ToString(dataGridView1.Rows[i].Cells["customer_adress"].EditedFormattedValue.ToString());

                    item.customer_shuihao = Convert.ToString(dataGridView1.Rows[i].Cells["customer_shuihao"].EditedFormattedValue.ToString());

                    item.customer_bank = Convert.ToString(dataGridView1.Rows[i].Cells["customer_bank"].EditedFormattedValue.ToString());

                    item.customer_account = Convert.ToString(dataGridView1.Rows[i].Cells["customer_account"].EditedFormattedValue.ToString());

                    item.customer_phone = Convert.ToString(dataGridView1.Rows[i].Cells["customer_phone"].EditedFormattedValue.ToString());

                    item.customer_contact = Convert.ToString(dataGridView1.Rows[i].Cells["customer_contact"].EditedFormattedValue.ToString());

                    item.Input_Date  = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));
                    item.customer_id = model.customer_id;

                    #endregion

                    #region MyRegion
                    var    startAt    = this.stockOutDateTimePicker.Value.AddDays(0).Date;
                    string conditions = "";

                    #region  构造查询条件
                    if (item.customer_name != null)
                    {
                        conditions += " customer_name ='" + item.customer_name + "'";
                    }
                    if (item.customer_adress != null)
                    {
                        conditions += " ,customer_adress ='" + item.customer_adress + "'";
                    }
                    if (item.customer_shuihao != null)
                    {
                        conditions += " ,customer_shuihao ='" + item.customer_shuihao + "'";
                    }
                    if (item.customer_bank != null)
                    {
                        conditions += " ,customer_bank ='" + item.customer_bank + "'";
                    }
                    if (item.customer_account != null)
                    {
                        conditions += " ,customer_account ='" + item.customer_account + "'";
                    }
                    if (item.customer_phone != null)
                    {
                        conditions += " ,customer_phone ='" + item.customer_phone + "'";
                    }
                    if (item.customer_contact != null)
                    {
                        conditions += " ,customer_contact ='" + item.customer_contact + "'";
                    }
                    if (item.Input_Date != null)
                    {
                        conditions += " ,Input_Date ='" + item.Input_Date.ToString("yyyy/MM/dd") + "'";
                    }
                    conditions = "update JNOrder_customer set  " + conditions + " where customer_id = " + item.customer_id + " ";

                    // conditions += " order by Id desc";
                    #endregion
                    #endregion

                    int isrun = BusinessHelp.updatecustomer_Server(conditions);


                    if (arg.CurrentIndex % 5 == 0)
                    {
                        backgroundWorker2.ReportProgress(progress, arg);
                    }
                }
                backgroundWorker2.ReportProgress(100, arg);
                e.Result = string.Format("{0} 已保存 !", changeindex.Count);
            }
            catch (Exception ex)
            {
                if (!e.Cancel)
                {
                    e.Result = ex.Message + "";
                }
                success = false;
            }

            return(success);
        }
Beispiel #10
0
        private bool dailysaveList(BackgroundWorker worker, DoWorkEventArgs e)
        {
            WorkerArgument arg          = e.Argument as WorkerArgument;
            clsAllnew      BusinessHelp = new clsAllnew();
            bool           success      = true;

            try
            {
                int rowCount = changeindex.Count;
                arg.OrderCount = rowCount;
                int j        = 1;
                int progress = 0;
                #region MyRegion
                for (int ik = 0; ik < changeindex.Count; ik++)
                {
                    j = ik;

                    arg.CurrentIndex = j + 1;
                    progress         = Convert.ToInt16(((j + 1) * 1.0 / rowCount) * 100);

                    int i   = changeindex[ik];
                    var row = dataGridView1.Rows[i];

                    var model = row.DataBoundItem as clsDATAinfo;

                    clsDATAinfo item = new clsDATAinfo();

                    item.zhenghao = Convert.ToString(dataGridView1.Rows[i].Cells["zhenghao"].EditedFormattedValue.ToString());

                    item.xingming = Convert.ToString(dataGridView1.Rows[i].Cells["xingming"].EditedFormattedValue.ToString());

                    item.xingbie = Convert.ToString(dataGridView1.Rows[i].Cells["xingbie"].EditedFormattedValue.ToString());

                    item.zuoyeleibie = Convert.ToString(dataGridView1.Rows[i].Cells["zuoyeleibie"].EditedFormattedValue.ToString());

                    item.zhuncaoxiangmu = Convert.ToString(dataGridView1.Rows[i].Cells["zhuncaoxiangmu"].EditedFormattedValue.ToString());

                    item.chulingriqi = Convert.ToString(dataGridView1.Rows[i].Cells["chulingriqi"].EditedFormattedValue.ToString());

                    item.youxiangqixian = Convert.ToString(dataGridView1.Rows[i].Cells["youxiangqixian"].EditedFormattedValue.ToString());

                    item.fushenriqi = Convert.ToString(dataGridView1.Rows[i].Cells["fushenriqi"].EditedFormattedValue.ToString());


                    item.xinzeng = Convert.ToString(dataGridView1.Rows[i].Cells["xinzeng"].EditedFormattedValue.ToString());
                    item.Message = Convert.ToString(dataGridView1.Rows[i].Cells["Message"].EditedFormattedValue.ToString());//印章类型

                    item.Input_Date = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));
                    item.Item_ID    = model.Item_ID;

                    #endregion

                    #region MyRegion
                    var startAt = this.stockOutDateTimePicker.Value.AddDays(0).Date;
                    #region  构造查询条件
                    string conditions = "";
                    conditions = BusinessHelp.sql_yuju(e, item, conditions);
                    #endregion
                    #endregion

                    int isrun = BusinessHelp.update_Server(conditions, item);
                    if (item.xinzeng == "true" && isrun == 1)
                    {
                        item.xinzeng = "";
                    }

                    if (arg.CurrentIndex % 5 == 0)
                    {
                        backgroundWorker2.ReportProgress(progress, arg);
                    }
                }
                backgroundWorker2.ReportProgress(100, arg);
                e.Result = string.Format("{0} 已保存 !", changeindex.Count);
            }
            catch (Exception ex)
            {
                if (!e.Cancel)
                {
                    e.Result = ex.Message + "";
                }
                success = false;
            }

            return(success);
        }
Beispiel #11
0
        private bool dailysaveList(BackgroundWorker worker, DoWorkEventArgs e)
        {
            WorkerArgument arg          = e.Argument as WorkerArgument;
            clsAllnew      BusinessHelp = new clsAllnew();
            bool           success      = true;

            try
            {
                int rowCount = changeindex.Count;
                arg.OrderCount = rowCount;
                int j        = 1;
                int progress = 0;
                #region MyRegion
                for (int ik = 0; ik < changeindex.Count; ik++)
                {
                    j = ik;

                    arg.CurrentIndex = j + 1;
                    progress         = Convert.ToInt16(((j + 1) * 1.0 / rowCount) * 100);

                    int i   = changeindex[ik];
                    var row = dataGridView1.Rows[i];

                    var model = row.DataBoundItem as clsOrderinfo;

                    clsOrderinfo item = new clsOrderinfo();

                    item.hetongbianhao = Convert.ToString(dataGridView1.Rows[i].Cells["hetongbianhao"].EditedFormattedValue.ToString());

                    item.kehuxingming = Convert.ToString(dataGridView1.Rows[i].Cells["kehuxingming"].EditedFormattedValue.ToString());

                    item.kehudizhi = Convert.ToString(dataGridView1.Rows[i].Cells["kehudizhi"].EditedFormattedValue.ToString());

                    item.lianxidianhua = Convert.ToString(dataGridView1.Rows[i].Cells["lianxidianhua"].EditedFormattedValue.ToString());

                    item.hetongdaoqishijian = Convert.ToString(dataGridView1.Rows[i].Cells["hetongdaoqishijian"].EditedFormattedValue.ToString());

                    item.hetongshichang = Convert.ToString(dataGridView1.Rows[i].Cells["hetongshichang"].EditedFormattedValue.ToString());

                    item.shishou = Convert.ToString(dataGridView1.Rows[i].Cells["shishou"].EditedFormattedValue.ToString());

                    item.yuejia = Convert.ToString(dataGridView1.Rows[i].Cells["yuejia"].EditedFormattedValue.ToString());

                    item.mianji = Convert.ToString(dataGridView1.Rows[i].Cells["mianji"].EditedFormattedValue.ToString());

                    item.tixingshoufeishijian = Convert.ToString(dataGridView1.Rows[i].Cells["tixingshoufeishijian"].EditedFormattedValue.ToString());
                    item.meiyuanci            = Convert.ToString(dataGridView1.Rows[i].Cells["meiyuanci"].EditedFormattedValue.ToString());
                    item.zongcishu            = Convert.ToString(dataGridView1.Rows[i].Cells["zongcishu"].EditedFormattedValue.ToString());
                    item.shengyushu           = Convert.ToString(dataGridView1.Rows[i].Cells["shengyushu"].EditedFormattedValue.ToString());
                    item.chaboli    = Convert.ToString(dataGridView1.Rows[i].Cells["chaboli"].EditedFormattedValue.ToString());
                    item.kehuyaoqiu = Convert.ToString(dataGridView1.Rows[i].Cells["kehuyaoqiu"].EditedFormattedValue.ToString());
                    item.beizhu     = Convert.ToString(dataGridView1.Rows[i].Cells["beizhu"].EditedFormattedValue.ToString());
                    item.xinzeng    = Convert.ToString(dataGridView1.Rows[i].Cells["xinzeng"].EditedFormattedValue.ToString());
                    item.Message    = Convert.ToString(dataGridView1.Rows[i].Cells["Message"].EditedFormattedValue.ToString());

                    item.Input_Date = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));
                    item.order_id   = model.order_id;

                    #endregion

                    #region MyRegion
                    var startAt = this.stockOutDateTimePicker.Value.AddDays(0).Date;


                    #region  构造查询条件
                    string conditions = "";
                    conditions = sql_yuju(e, item, conditions);
                    // conditions += " order by Id desc";
                    #endregion
                    #endregion

                    int isrun = BusinessHelp.updatecustomer_Server(conditions);
                    if (item.xinzeng == "true" && isrun == 1)
                    {
                        item.xinzeng = "";
                    }

                    if (arg.CurrentIndex % 5 == 0)
                    {
                        backgroundWorker2.ReportProgress(progress, arg);
                    }
                }
                backgroundWorker2.ReportProgress(100, arg);
                e.Result = string.Format("{0} 已保存 !", changeindex.Count);
            }
            catch (Exception ex)
            {
                if (!e.Cancel)
                {
                    e.Result = ex.Message + "";
                }
                success = false;
            }

            return(success);
        }
Beispiel #12
0
        private bool dailysaveList(BackgroundWorker worker, DoWorkEventArgs e)
        {
            WorkerArgument arg          = e.Argument as WorkerArgument;
            clsAllnew      BusinessHelp = new clsAllnew();
            bool           success      = true;

            try
            {
                int rowCount = changeindex.Count;
                arg.OrderCount = rowCount;
                int j        = 1;
                int progress = 0;
                #region MyRegion
                for (int ik = 0; ik < changeindex.Count; ik++)
                {
                    j = ik;

                    arg.CurrentIndex = j + 1;
                    progress         = Convert.ToInt16(((j + 1) * 1.0 / rowCount) * 100);

                    int i   = changeindex[ik];
                    var row = dataGridView1.Rows[i];

                    var model = row.DataBoundItem as clsLog_info;

                    clsLog_info item = new clsLog_info();

                    item.product_no = Convert.ToString(dataGridView1.Rows[i].Cells["product_no"].EditedFormattedValue.ToString());

                    item.indent = Convert.ToString(dataGridView1.Rows[i].Cells["indent"].EditedFormattedValue.ToString());

                    item.indent_date = Convert.ToString(dataGridView1.Rows[i].Cells["indent_date"].EditedFormattedValue.ToString());

                    item.end_user = Convert.ToString(dataGridView1.Rows[i].Cells["end_user"].EditedFormattedValue.ToString());

                    item.vendor = Convert.ToString(dataGridView1.Rows[i].Cells["vendor"].EditedFormattedValue.ToString());

                    item.daohuoshijian = Convert.ToString(dataGridView1.Rows[i].Cells["daohuoshijian"].EditedFormattedValue.ToString());
                    item.xinzeng       = Convert.ToString(dataGridView1.Rows[i].Cells["xinzeng"].EditedFormattedValue.ToString());

                    item.Input_Date = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));
                    item.Log_id     = model.Log_id;

                    #endregion

                    #region MyRegion
                    var    startAt    = this.stockOutDateTimePicker.Value.AddDays(0).Date;
                    string conditions = "";

                    #region  构造查询条件
                    if (item.product_no != null)
                    {
                        conditions += " product_no ='" + item.product_no + "'";
                    }
                    if (item.indent != null)
                    {
                        conditions += " ,indent ='" + item.indent + "'";
                    }
                    if (item.indent_date != null)
                    {
                        conditions += " ,indent_date ='" + item.indent_date + "'";
                    }
                    if (item.end_user != null)
                    {
                        conditions += " ,end_user ='******'";
                    }
                    if (item.vendor != null)
                    {
                        conditions += " ,vendor ='" + item.vendor + "'";
                    }
                    if (item.daohuoshijian != null)
                    {
                        conditions += " ,daohuoshijian ='" + item.daohuoshijian + "'";
                    }

                    if (item.Input_Date != null)
                    {
                        conditions += " ,Input_Date ='" + item.Input_Date.ToString("yyyy/MM/dd") + "'";
                    }
                    if (item.xinzeng == "true")
                    {
                        conditions = "insert into JNOrder_log(product_no,indent,indent_date,end_user,vendor,Input_Date) values ('" + item.product_no + "','" + item.indent + "','" + item.indent_date + "','" + item.end_user + "','" + item.vendor + "','" + item.Input_Date.ToString("yyyy/MM/dd") + "')";
                    }
                    else
                    {
                        conditions = "update JNOrder_log set  " + conditions + " where Log_id = " + item.Log_id + " ";
                    }

                    #endregion
                    #endregion

                    int isrun = BusinessHelp.updateLog_Server(conditions);
                    if (item.xinzeng == "true" && isrun == 1)
                    {
                        item.xinzeng = "";
                    }


                    if (arg.CurrentIndex % 5 == 0)
                    {
                        backgroundWorker2.ReportProgress(progress, arg);
                    }
                }
                backgroundWorker2.ReportProgress(100, arg);
                e.Result = string.Format("{0} 已保存 !", changeindex.Count);
            }
            catch (Exception ex)
            {
                if (!e.Cancel)
                {
                    e.Result = ex.Message + "";
                }
                success = false;
            }

            return(success);
        }
        private bool dailysaveList(BackgroundWorker worker, DoWorkEventArgs e)
        {
            WorkerArgument arg = e.Argument as WorkerArgument;
            clsAllnew BusinessHelp = new clsAllnew();
            bool success = true;
            try
            {

                int rowCount = changeindex.Count;
                arg.OrderCount = rowCount;
                int j = 1;
                int progress = 0;
                #region MyRegion
                for (int ik = 0; ik < changeindex.Count; ik++)
                {
                    j = ik;

                    arg.CurrentIndex = j + 1;
                    progress = Convert.ToInt16(((j + 1) * 1.0 / rowCount) * 100);

                    int i = changeindex[ik];
                    var row = dataGridView1.Rows[i];

                    var model = row.DataBoundItem as clsOrderinfo;

                    clsOrderinfo item = new clsOrderinfo();

                    item.customer_name = Convert.ToString(dataGridView1.Rows[i].Cells["customer_name"].EditedFormattedValue.ToString());
                    if (dataGridView1.Rows[i].Cells["dinghuoshijian"].EditedFormattedValue.ToString() != "")
                        item.dinghuoshijian = Convert.ToDateTime(dataGridView1.Rows[i].Cells["dinghuoshijian"].EditedFormattedValue.ToString());

                    item.order_no = Convert.ToString(dataGridView1.Rows[i].Cells["order_no"].EditedFormattedValue.ToString());

                    item.Product_no = Convert.ToString(dataGridView1.Rows[i].Cells["Product_no"].EditedFormattedValue.ToString());

                    item.Product_name = Convert.ToString(dataGridView1.Rows[i].Cells["Product_name"].EditedFormattedValue.ToString());

                    item.shuliang = Convert.ToString(dataGridView1.Rows[i].Cells["shuliang"].EditedFormattedValue.ToString());

                    item.Product_salse = Convert.ToString(dataGridView1.Rows[i].Cells["Product_salse"].EditedFormattedValue.ToString());

                    item.jine = Convert.ToString(dataGridView1.Rows[i].Cells["jine"].EditedFormattedValue.ToString());

                    if (dataGridView1.Rows[i].Cells["yujijiaohuoshijian"].EditedFormattedValue.ToString() != null && dataGridView1.Rows[i].Cells["yujijiaohuoshijian"].EditedFormattedValue.ToString() != "")
                        item.yujijiaohuoshijian = Convert.ToDateTime(dataGridView1.Rows[i].Cells["yujijiaohuoshijian"].EditedFormattedValue.ToString());
                    if (dataGridView1.Rows[i].Cells["jianhuoshijian2"].EditedFormattedValue.ToString() != null && dataGridView1.Rows[i].Cells["jianhuoshijian2"].EditedFormattedValue.ToString() != "")
                        item.jianhuoshijian2 = Convert.ToDateTime(dataGridView1.Rows[i].Cells["jianhuoshijian2"].EditedFormattedValue.ToString());

                    item.dingdanguanliyuan = Convert.ToString(dataGridView1.Rows[i].Cells["dingdanguanliyuan"].EditedFormattedValue.ToString());

                    item.kaipiao = Convert.ToString(dataGridView1.Rows[i].Cells["kaipiao"].EditedFormattedValue.ToString());


                    item.shifoujiaohuo = Convert.ToString(dataGridView1.Rows[i].Cells["shifoujiaohuo"].EditedFormattedValue.ToString());
                    if (dataGridView1.Rows[i].Cells["fukuanriqi"].EditedFormattedValue.ToString() != null && dataGridView1.Rows[i].Cells["fukuanriqi"].EditedFormattedValue.ToString() != "")
                        item.fukuanriqi = Convert.ToDateTime(dataGridView1.Rows[i].Cells["fukuanriqi"].EditedFormattedValue.ToString());

                    item.beizhu = Convert.ToString(dataGridView1.Rows[i].Cells["beizhu"].EditedFormattedValue.ToString());

                    item.xinzeng = Convert.ToString(dataGridView1.Rows[i].Cells["xinzeng"].EditedFormattedValue.ToString());

                    item.Input_Date = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd"));
                    item.order_id = model.order_id;

                #endregion

                    #region MyRegion
                    var startAt = this.stockOutDateTimePicker.Value.AddDays(0).Date;
                    string conditions = "";

                    #region  构造查询条件
                    if (item.customer_name != null)
                    {
                        conditions += " customer_name ='" + item.customer_name + "'";
                    }
                    if (item.dinghuoshijian != null)
                    {
                        conditions += " ,dinghuoshijian ='" + item.dinghuoshijian.ToString("yyyy/MM/dd") + "'";
                    }
                    if (item.order_no != null)
                    {
                        conditions += " ,order_no ='" + item.order_no + "'";
                    }
                    if (item.Product_no != null)
                    {
                        conditions += " ,Product_no ='" + item.Product_no + "'";
                    }
                    if (item.Product_name != null)
                    {
                        conditions += " ,Product_name ='" + item.Product_name + "'";
                    }

                    if (item.shuliang != null)
                    {
                        conditions += " ,shuliang ='" + item.shuliang + "'";
                    }

                    if (item.Product_salse != null)
                    {
                        conditions += " ,Product_salse ='" + item.Product_salse + "'";
                    }

                    if (item.jine != null)
                    {
                        conditions += " ,jine ='" + item.jine + "'";
                    }

                    if (item.yujijiaohuoshijian != null && item.yujijiaohuoshijian != Convert.ToDateTime("01/01/0001 00:00:00"))
                    {
                        conditions += " ,yujijiaohuoshijian ='" + item.yujijiaohuoshijian.ToString("yyyy/MM/dd") + "'";
                    }

                    if (item.jianhuoshijian2 != null && item.jianhuoshijian2 != Convert.ToDateTime("01/01/0001 00:00:00"))
                    {
                        conditions += " ,jianhuoshijian2 ='" + item.jianhuoshijian2.ToString("yyyy/MM/dd") + "'";
                    }

                    if (item.dingdanguanliyuan != null)
                    {
                        conditions += " ,dingdanguanliyuan ='" + item.dingdanguanliyuan + "'";
                    }

                    if (item.kaipiao != null)
                    {
                        conditions += " ,kaipiao ='" + item.kaipiao + "'";
                    }

                    if (item.shifoujiaohuo != null)
                    {
                        conditions += " ,shifoujiaohuo ='" + item.shifoujiaohuo + "'";
                    }

                    if (item.fukuanriqi != null && item.fukuanriqi != Convert.ToDateTime("01/01/0001 00:00:00"))
                    {
                        conditions += " ,fukuanriqi ='" + item.fukuanriqi.ToString("yyyy/MM/dd") + "'";
                    }

                    if (item.beizhu != null)
                    {
                        conditions += " ,beizhu ='" + item.beizhu + "'";
                    }
                    if (item.Input_Date != null)
                    {
                        conditions += " ,Input_Date ='" + item.Input_Date.ToString("yyyy/MM/dd") + "'";
                    }
                    if (item.xinzeng == "true")
                        conditions = "insert into JNOrder_order(customer_name,dinghuoshijian,order_no,Product_no,Product_name,shuliang,Product_salse,jine,yujijiaohuoshijian,jianhuoshijian2,dingdanguanliyuan,kaipiao,shifoujiaohuo,fukuanriqi,beizhu,Input_Date) values ('" + item.customer_name + "','" + item.dinghuoshijian.ToString("yyyy/MM/dd") + "','" + item.order_no + "','" + item.Product_no + "','" + item.Product_name + "','" + item.shuliang + "','" + item.Product_salse + "','" + item.jine + "','" + item.yujijiaohuoshijian.ToString("yyyy/MM/dd") + "','" + item.jianhuoshijian2.ToString("yyyy/MM/dd") + "','" + item.dingdanguanliyuan + "','" + item.kaipiao + "','" + item.shifoujiaohuo + "','" + item.fukuanriqi.ToString("yyyy/MM/dd") + "','" + item.beizhu + "','" + item.Input_Date.ToString("yyyy/MM/dd") + "')";
                    else
                        conditions = "update JNOrder_order set  " + conditions + " where order_id = " + item.order_id + " ";

                    // conditions += " order by Id desc";
                    #endregion
                    #endregion

                    int isrun = BusinessHelp.updateProduct_Server(conditions);
                    if (item.xinzeng == "true" && isrun == 1)
                        item.xinzeng = "";


                    if (arg.CurrentIndex % 5 == 0)
                    {
                        backgroundWorker2.ReportProgress(progress, arg);
                    }
                }
                backgroundWorker2.ReportProgress(100, arg);
                e.Result = string.Format("{0} 已保存 !", changeindex.Count);

            }
            catch (Exception ex)
            {
                if (!e.Cancel)
                {

                    e.Result = ex.Message + "";
                }
                success = false;
            }

            return success;
        }
Beispiel #14
0
        private void FormChanging_Shown(object sender, EventArgs e)
        {
            WorkerArgument args = new WorkerArgument(listview, labelCurrentFile);

            backgroundWorkerRename.RunWorkerAsync(args);
        }