示例#1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            // Get the BackgroundWorker that raised this event.
            BackgroundWorker worker = sender as BackgroundWorker;
            CallParameter    cp     = (CallParameter)e.Argument;

            e.Result = SearchExistingProducts_multiThread(cp.homeid, cp.areaid, cp.groupid, cp.productid);
        }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            // Get the BackgroundWorker that raised this event.
            BackgroundWorker worker = sender as BackgroundWorker;
            CallParameter    cp     = (CallParameter)e.Argument;

            e.Result = cr.LoadHomeModelQuantity_Multithread(cp.stateid.ToString(), cp.areaid.ToString(), cp.groupid.ToString(), cp.brandid.ToString());
        }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            // Get the BackgroundWorker that raised this event.
            BackgroundWorker worker = sender as BackgroundWorker;
            CallParameter    cp     = (CallParameter)e.Argument;

            // Assign the result of the computation
            // to the Result property of the DoWorkEventArgs
            // object. This is will be available to the
            // RunWorkerCompleted eventhandler.
            e.Result = cr.CopyProductConfiguration(cp.sourceproductid, cp.targetproductid, cp.usercode);
        }
示例#4
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            // Get the BackgroundWorker that raised this event.
            BackgroundWorker worker = sender as BackgroundWorker;
            CallParameter    cp     = (CallParameter)e.Argument;

            // Assign the result of the computation
            // to the Result property of the DoWorkEventArgs
            // object. This is will be available to the
            // RunWorkerCompleted eventhandler.
            e.Result = SearchProductPrice1(cp.stateid, cp.regionid, cp.status, cp.productid, cp.productname, cp.productdesc, cp.studiomproduct);
        }
        public void Refresh()
        {
            this.loadingimage.Image = global::SQSAdmin_WpfCustomControlLibrary.Properties.Resources.processingImage;
            CallParameter cp = new CallParameter();

            cp.stateid = cr.LoginState;
            cp.brandid = int.Parse(cmbBrand.SelectedValue.ToString());
            cp.areaid  = int.Parse(cmbArea.SelectedValue.ToString());
            cp.groupid = int.Parse(cmbGroup.SelectedValue.ToString());

            imagebox.Visibility = Visibility.Visible;
            backgroundWorker2.RunWorkerAsync(cp);
        }
示例#6
0
        public void SearchExistingProducts()
        {
            CallParameter cp = new CallParameter();

            cp.homeid    = homeid;
            cp.productid = txtProductID2.Text;
            cp.areaid    = int.Parse(cmbArea2.SelectedValue.ToString());
            cp.groupid   = int.Parse(cmbGroup2.SelectedValue.ToString());

            this.loadingimage.Image = global::SQSAdmin_WpfCustomControlLibrary.Properties.Resources.processingImage;
            imagebox.Visibility     = Visibility.Visible;
            backgroundWorker1.RunWorkerAsync(cp);
            //cr.LoadHomeExistingPAG(homeid, int.Parse(cmbArea2.SelectedValue.ToString()), int.Parse(cmbGroup2.SelectedValue.ToString()), txtProductID2.Text);
        }
示例#7
0
        //private string SearchAvailableProducts(System.ComponentModel.BackgroundWorker worker, System.ComponentModel.DoWorkEventArgs e, int areaid, int groupid, string productstring, string pagid)
        private void SearchAvailableProducts_MultiThread()
        {
            CallParameter cp = new CallParameter();

            cp.promotionid   = promotionid;
            cp.areaid        = int.Parse(cmbArea.SelectedValue.ToString());
            cp.groupid       = int.Parse(cmbGroup.SelectedValue.ToString());
            cp.productstring = txtProductID.Text;
            cp.pagid         = txtPAGID.Text;

            imagebox.Visibility = Visibility.Visible;
            backgroundWorker1.RunWorkerAsync(cp);

            //DataSet ds = client.SQSAdmin_Promotion_GetAvailableProductsForPromotion(promotionid, areaid, groupid, productstring, pagid);

            //dataGrid1.DataContext = ds.Tables[0];
        }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            List <PriceErrorList> list = new List <PriceErrorList>();

            try
            {
                CallParameter cp3 = (CallParameter)e.Argument;
                ExcelTable = cr.readExcelFileToDataTable(cp3.FileName, "QuantitySheet$");

                if (ExcelTable != null && ExcelTable.Columns.Count == 3)
                {
                    if (ExcelTable.Columns[0].ColumnName.Trim().ToUpper() != "HOMEPRODUCTID" ||
                        ExcelTable.Columns[1].ColumnName.Trim().ToUpper() != "PRODUCTAREAGROUPID" ||
                        ExcelTable.Columns[2].ColumnName.Trim().ToUpper() != "QUANTITY"
                        )
                    {
                        PriceErrorList l = new PriceErrorList();
                        l.MessageText = "Column name or number does not match standard format.";
                        list.Add(l);
                        e.Result = list;
                    }
                    else
                    {
                        e.Result = IsSourceValidate(ExcelTable);
                    }
                }
                else
                {
                    imagebox.Visibility = Visibility.Collapsed;
                    MessageBox.Show("Can not find correct format sheet to import.");
                    btnContinue.IsEnabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                btnContinue.IsEnabled = false;
            }
        }
示例#9
0
        private void btnImport_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            openFileDialog1.Filter      = "Excel Files|*.xls;*.xlsx;*.xlsm";
            openFileDialog1.FilterIndex = 1;
            ErrorGrid.DataContext       = null;

            openFileDialog1.Multiselect = false;

            System.Windows.Forms.DialogResult result = openFileDialog1.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                string filename = openFileDialog1.FileName;
                if (filename != "")
                {
                    imagebox.Visibility     = Visibility.Visible;
                    this.loadingimage.Image = global::SQSAdmin_WpfCustomControlLibrary.Properties.Resources.processingImage;

                    try
                    {
                        CallParameter cp = new CallParameter();
                        cp.State    = stateid.ToString();
                        cp.UserCode = usercode;
                        cp.FileName = filename;

                        if (!backgroundWorker1.IsBusy)
                        {
                            backgroundWorker1.RunWorkerAsync(cp);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
示例#10
0
        private void Search()
        {
            int           studiomproduct = 0;
            CallParameter cp             = new CallParameter();

            if ((bool)chkStudioM.IsChecked)
            {
                studiomproduct = 1;
            }

            cp.stateid        = cr.LoginState;
            cp.regionid       = int.Parse(cmbRegion.SelectedValue.ToString());
            cp.status         = int.Parse(cmbStatus.SelectedValue.ToString());
            cp.productid      = txtProductID.Text;
            cp.productname    = txtProductName.Text;
            cp.productdesc    = txtProductDesc.Text;
            cp.studiomproduct = studiomproduct;
            MySetting.Default.SearchProductID   = txtProductID.Text;
            MySetting.Default.SearchProductName = txtProductName.Text;
            MySetting.Default.SearchProsuctDesc = txtProductDesc.Text;

            imagebox.Visibility = Visibility.Visible;
            backgroundWorker1.RunWorkerAsync(cp);
        }
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            CallParameter cp = (CallParameter)e.Argument;

            e.Result = SearchAvailableProducts1(loginstateid.ToString(), cp.areaid.ToString(), cp.groupid.ToString(), cp.productstring, cp.pagid);
        }
        private void btnCopy_Click(object sender, RoutedEventArgs e)
        {
            string sourceproductid = "";
            string targetproductid = "";



            var itemsSource = dataGrid2.ItemsSource as IEnumerable;

            if (itemsSource != null)
            {
                foreach (var item in itemsSource)
                {
                    var row = dataGrid2.ItemContainerGenerator.ContainerFromItem(item) as Microsoft.Windows.Controls.DataGridRow;
                    ContentPresenter contentPresenter = dataGrid2.Columns[0].GetCellContent(item) as ContentPresenter;

                    if (contentPresenter != null)
                    {
                        DataTemplate editingTemplate = contentPresenter.ContentTemplate;
                        CheckBox     chk             = editingTemplate.FindName("chkSelected2", contentPresenter) as CheckBox;
                        if ((bool)chk.IsChecked)
                        {
                            TextBlock tx = dataGrid2.Columns[1].GetCellContent(row) as TextBlock;
                            sourceproductid = tx.Text;
                            break;
                        }
                    }
                }
            }

            // get target product
            var itemsSource1 = dataGrid1.ItemsSource as IEnumerable;

            if (itemsSource1 != null)
            {
                foreach (var item in itemsSource1)
                {
                    var row = dataGrid1.ItemContainerGenerator.ContainerFromItem(item) as Microsoft.Windows.Controls.DataGridRow;
                    ContentPresenter contentPresenter = dataGrid1.Columns[0].GetCellContent(item) as ContentPresenter;

                    if (contentPresenter != null)
                    {
                        DataTemplate editingTemplate = contentPresenter.ContentTemplate;
                        CheckBox     chk             = editingTemplate.FindName("chkSelected", contentPresenter) as CheckBox;
                        if ((bool)chk.IsChecked)
                        {
                            TextBlock tx = dataGrid1.Columns[1].GetCellContent(row) as TextBlock;
                            if (targetproductid == "")
                            {
                                targetproductid = tx.Text;
                            }
                            else
                            {
                                targetproductid = targetproductid + "," + tx.Text;
                            }
                        }
                    }
                }
            }

            if (sourceproductid == targetproductid)
            {
                MessageBox.Show("Target product is same as source product. No configuration copied.");
            }
            else if (sourceproductid != "" && targetproductid != "")
            {
                CallParameter cp = new CallParameter();
                cp.sourceproductid  = sourceproductid;
                cp.targetproductid  = targetproductid;
                cp.usercode         = usercode;
                imagebox.Opacity    = 0.7;
                imagebox.Visibility = Visibility.Visible;

                backgroundWorker1.RunWorkerAsync(cp);
                //string result = cr.CopyProductConfiguration(sourceproductid, targetproductid, usercode);
                //MessageBox.Show(result.Replace(@"\r\n", System.Environment.NewLine));
            }
            else
            {
                MessageBox.Show("Wrong source or target product ID. please check.");
            }
        }
示例#13
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            List <ErrorList> list = new List <ErrorList>();

            ExcelTableFinal = new DataTable();
            try
            {
                CallParameter cp3 = (CallParameter)e.Argument;
                ExcelTable = cr.readExcelFileToDataTable(cp3.FileName, "ProductSheet$");
                while (ExcelTable.Columns.Count > 17)
                {
                    ExcelTable.Columns.RemoveAt(17);
                }


                ExcelTableFinal = ExcelTable.Clone();
                ExcelTable.AsEnumerable().Where(row => row["product id"] != null && row["product id"].ToString() != "").ToList().ForEach(row => ExcelTableFinal.ImportRow(row));

                if (ExcelTableFinal != null)
                {
                    if (ExcelTable.Columns[0].ColumnName.Trim().ToUpper() != "PRODUCT ID" ||
                        ExcelTable.Columns[1].ColumnName.Trim().ToUpper() != "PRODUCT NAME" ||
                        ExcelTable.Columns[2].ColumnName.Trim().ToUpper() != "PRODUCT DESCRIPTION" ||
                        ExcelTable.Columns[3].ColumnName.Trim().ToUpper() != "UOM" ||
                        ExcelTable.Columns[4].ColumnName.Trim().ToUpper() != "SORT ORDER" ||
                        ExcelTable.Columns[5].ColumnName.Trim().ToUpper() != "ACTIVE" ||
                        ExcelTable.Columns[6].ColumnName.Trim().ToUpper() != "BC ACTIVE" ||
                        ExcelTable.Columns[7].ColumnName.Trim().ToUpper() != "PRODUCT CATEGORY" ||
                        ExcelTable.Columns[8].ColumnName.Trim().ToUpper() != "PRODUCT CODE" ||
                        ExcelTable.Columns[9].ColumnName.Trim().ToUpper() != "PRICE DISPLAY CODE" ||
                        ExcelTable.Columns[10].ColumnName.Trim().ToUpper() != "COST CENTRE CODE" ||
                        ExcelTable.Columns[11].ColumnName.Trim().ToUpper() != "MINI BILL COMPLETED" ||
                        ExcelTable.Columns[12].ColumnName.Trim().ToUpper() != "STATE" ||
                        ExcelTable.Columns[13].ColumnName.Trim().ToUpper() != "ISSTUDIOMPRODUCT" ||
                        ExcelTable.Columns[14].ColumnName.Trim().ToUpper() != "INTERNAL DESCRIPTION" ||
                        ExcelTable.Columns[15].ColumnName.Trim().ToUpper() != "ADDITIONAL NOTES" ||
                        ExcelTable.Columns[16].ColumnName.Trim().ToUpper() != "OPERATION ONLY"
                        )
                    {
                        ErrorList l = new ErrorList();
                        l.MessageText = "Column name or number does not match standard format.";
                        list.Add(l);
                        e.Result = list;
                    }
                    else
                    {
                        e.Result = IsSourceValidate(ExcelTableFinal);
                    }
                }
                else
                {
                    ErrorList l = new ErrorList();
                    l.MessageText = "The excel is empty.";
                    list.Add(l);
                    e.Result = list;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            List <PriceErrorList> list   = new List <PriceErrorList>();
            SQSAdminServiceClient client = new SQSAdminServiceClient();

            client.Endpoint.Address = new System.ServiceModel.EndpointAddress(CommonVariables.WcfEndpoint);
            try
            {
                CallParameter cp3 = (CallParameter)e.Argument;
                ExcelTable = cr.readExcelFileToDataTable(cp3.FileName, "PriceSheet$");

                if (ExcelTable != null && (ExcelTable.Columns.Count == 8 || ExcelTable.Columns.Count == 68 || ExcelTable.Columns.Count == 16))
                {
                    if (ExcelTable.Columns.Count == 8)// vertical format
                    {
                        if (ExcelTable.Columns[0].ColumnName.Trim().ToUpper() != "PRODUCTID" ||
                            ExcelTable.Columns[1].ColumnName.Trim().ToUpper() != "REGIONNAME" ||
                            ExcelTable.Columns[2].ColumnName.Trim().ToUpper() != "EFFECTIVEDATE" ||
                            ExcelTable.Columns[3].ColumnName.Trim().ToUpper() != "DIRECTBUILDCOST" ||
                            ExcelTable.Columns[4].ColumnName.Trim().ToUpper() != "BUILDINGTRANSFERCOST" ||
                            ExcelTable.Columns[5].ColumnName.Trim().ToUpper() != "SELLPRICE" ||
                            ExcelTable.Columns[6].ColumnName.Trim().ToUpper() != "TARGETMARGINPERCENT" ||
                            ExcelTable.Columns[7].ColumnName.Trim().ToUpper() != "DERIVEDCOST"
                            )
                        {
                            PriceErrorList l = new PriceErrorList();
                            l.MessageText = "Column name or number does not match standard format. Please follow the sample data sheet format.";
                            list.Add(l);
                            e.Result = list;
                        }
                        else
                        {
                            e.Result = IsSourceValidate(ExcelTable);
                        }
                    }
                    else if ((ExcelTable.Columns.Count == 16 && stateid == 2) || (ExcelTable.Columns.Count == 68 && stateid == 3))// NSW/QLD horizontal format
                    {
                        DataSet  dsTemp       = client.SQSAdmin_Generic_GetRegionList(stateid);
                        string[] colnamearray = new string[dsTemp.Tables[0].Rows.Count * 4 + 4];
                        int      idx          = 3;
                        foreach (DataRow dr in dsTemp.Tables[0].Rows)
                        {
                            colnamearray[idx] = dr["BCCode"].ToString().TrimStart().TrimEnd() + "_DIRECTBUILDCOST";
                            colnamearray[idx + dsTemp.Tables[0].Rows.Count]     = dr["BCCode"].ToString().TrimStart().TrimEnd() + "_BUILDINGTRANSFERCOST";
                            colnamearray[idx + dsTemp.Tables[0].Rows.Count * 2] = dr["BCCode"].ToString().TrimStart().TrimEnd() + "_TARGETMARGINPERCENT";
                            colnamearray[idx + dsTemp.Tables[0].Rows.Count * 3] = dr["BCCode"].ToString().TrimStart().TrimEnd() + "_SELLPRICE";
                            idx++;
                        }


                        if (ExcelTable.Columns[0].ColumnName.Trim().ToUpper() != "PRODUCTID" ||
                            ExcelTable.Columns[1].ColumnName.Trim().ToUpper() != "HOUSETYPE" ||
                            ExcelTable.Columns[2].ColumnName.Trim().ToUpper() != "EFFECTIVEDATE" ||
                            ExcelTable.Columns[ExcelTable.Columns.Count - 1].ColumnName.Trim().ToUpper() != "DERIVEDCOST")
                        {
                            PriceErrorList l = new PriceErrorList();
                            l.MessageText = "Column name or number does not match standard format.";
                            list.Add(l);
                            e.Result = list;
                        }
                        else
                        {
                            for (int i = 3; i < ExcelTable.Columns.Count - 2; i++)
                            {
                                if (ExcelTable.Columns[i].ColumnName.Trim().ToUpper() != colnamearray[i])
                                {
                                    PriceErrorList l = new PriceErrorList();
                                    l.MessageText = "Column name or number does not match standard format.";
                                    list.Add(l);
                                    e.Result = list;

                                    break;
                                }
                            }
                        }

                        e.Result = IsHorizontalSourceValidate(ExcelTable);
                    }
                    else
                    {
                        PriceErrorList l = new PriceErrorList();
                        l.MessageText = "Column name or number does not match standard format.";
                        list.Add(l);
                        e.Result = list;
                    }
                }
                else
                {
                    PriceErrorList l = new PriceErrorList();
                    l.MessageText = "Excel provided does not match the standard format.";
                    list.Add(l);
                    e.Result = list;
                }
            }
            catch (Exception ex)
            {
                PriceErrorList l = new PriceErrorList();
                l.MessageText = ex.Message;
                list.Add(l);
                e.Result = list;
            }
        }