예제 #1
0
        private void DoExport()
        {
            try
            {
                if (dataGridView1.DataSource != null && dataGridView1.Rows.Count > 0)
                {
                    List <PfCustomerStore>        list    = DataGridViewUtil.BindingListToList <PfCustomerStore>(dataGridView1.DataSource);
                    System.Collections.SortedList columns = new System.Collections.SortedList();
                    List <String> keys   = new List <string>();
                    List <String> values = new List <string>();
                    foreach (DataGridViewColumn item in dataGridView1.Columns)
                    {
                        if (item.Visible)
                        {
                            if (item.Name != "Column1" && item.Name != "Column2")
                            {
                                keys.Add(item.DataPropertyName);
                                values.Add(item.HeaderText);
                            }
                        }
                    }

                    /*    List<CostumeStore> ExportList = new List<CostumeStore>();
                     *  foreach (CostumeStore cItem in list)
                     *  {
                     *      CostumeStore curBrand = new CostumeStore();
                     *      curBrand.CostumeID = cItem.CostumeID;
                     *      curBrand.CostumeName = cItem.CostumeName;
                     *      curBrand.ColorName = cItem.ColorName;
                     *      curBrand.Price = cItem.Price;
                     *      curBrand.CostPrice = cItem.CostPrice;
                     *      curBrand.SalePrice = cItem.SalePrice;
                     *      curBrand.EmOnlinePrice = cItem.EmOnlinePrice;
                     *      curBrand.PfOnlinePrice = cItem.PfOnlinePrice;
                     *      curBrand.BrandName = cItem.BrandName;
                     *      curBrand.SupplierName = cItem.SupplierName;
                     *      curBrand.Year = cItem.Year;
                     *      curBrand.Season = cItem.Season;
                     *      curBrand.BigClass = cItem.BigClass;
                     *      curBrand.SmallClass = cItem.SmallClass;
                     *      curBrand.SubSmallClass = cItem.SubSmallClass;
                     *      curBrand.SizeGroupShowName = cItem.SizeGroupShowName;
                     *      curBrand.F = cItem.F;
                     *      curBrand.S = cItem.S;
                     *      curBrand.XS = cItem.XS;
                     *      curBrand.XL = cItem.XL;
                     *      curBrand.XL2 = cItem.XL2;
                     *      curBrand.XL3 = cItem.XL3;
                     *      curBrand.XL4 = cItem.XL4;
                     *      curBrand.XL5 = cItem.XL5;
                     *      curBrand.XL6 = cItem.XL6;
                     *      curBrand.M = cItem.M;
                     *      curBrand.L = cItem.L;
                     *      ExportList.Add(curBrand);
                     *  }*/



                    NPOIHelper.Keys   = keys.ToArray();
                    NPOIHelper.Values = values.ToArray();
                    NPOIHelper.ExportExcel(DataGridViewUtil.ToDataTable(list), path);

                    GlobalMessageBox.Show("导出完毕!");
                }
            }
            catch (Exception ex)
            { ShowError(ex); }
            finally
            {
                UnLockPage();
            }
        }
예제 #2
0
        private void BaseButton2_Click(object sender, EventArgs e)
        {
            try
            {
                if (GlobalUtil.EngineUnconnectioned(this))
                {
                    return;
                }
                List <Rule> itemList = null;
                if (dataGridViewRuleExpression.DataSource != null)
                {
                    itemList = DataGridViewUtil.BindingListToList <Rule>(dataGridViewRuleExpression.DataSource);
                }
                if (itemList == null)
                {
                    itemList = new List <Rule>();
                }

                if (this.numericUpDownRecharge.Value == 0)
                {
                    //金额不能为0

                    numericUpDownRecharge.Focus();
                    GlobalMessageBox.Show("金额不能为0!");
                    return;
                }
                else
                if (this.numericUpDownDonate.Value == 0)
                {
                    //金额不能为0

                    numericUpDownDonate.Focus();
                    GlobalMessageBox.Show("金额不能为0!");
                    return;
                }
                else
                if (itemList.Exists(i => i.RechargeMoney == Convert.ToInt32(this.numericUpDownRecharge.Text)))
                {
                    //充值金额重复

                    numericUpDownRecharge.Focus();
                    GlobalMessageBox.Show("充值金额重复!");
                    return;
                }
                else
                if (itemList.Exists(i => i.DonateMoney == Convert.ToInt32(this.numericUpDownDonate.Text)))
                {
                    //充值金额重复

                    numericUpDownDonate.Focus();
                    GlobalMessageBox.Show("赠送金额重复!");
                    return;
                }


                dataGridViewRuleExpression.DataSource = null;
                Rule curRule = new Rule();
                curRule.RechargeMoney = Convert.ToInt32(this.numericUpDownRecharge.Text);
                curRule.DonateMoney   = Convert.ToInt32(this.numericUpDownDonate.Text);
                itemList.Add(curRule);
                dataGridViewRuleExpression.DataSource = DataGridViewUtil.ListToBindingList(itemList);
                //if (dataGridViewRuleExpression != null)
                //{
                UpdateRule(dataGridViewRuleExpression);
                //}
                numericUpDownRecharge.Text = string.Empty;
                numericUpDownDonate.Text   = string.Empty;
            }
            catch (Exception ex)
            {
                GlobalUtil.ShowError(ex);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }
예제 #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!DataGridViewUtil.CheckPerrmisson(this, sender, e))
            {
                return;
            }
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }
            try
            {
                List <CostumeStoreChangeInfo> list = DataGridViewUtil.BindingListToList <CostumeStoreChangeInfo>(dataGridView1.DataSource);
                CostumeStoreChangeInfo        item = (CostumeStoreChangeInfo)list[e.RowIndex];


                if (e.ColumnIndex == inDataGridViewTextBoxColumn.Index ||
                    e.ColumnIndex == intoDataGridViewTextBoxColumn.Index ||
                    e.ColumnIndex == returnDataGridViewTextBoxColumn.Index ||
                    e.ColumnIndex == turnOutDataGridViewTextBoxColumn.Index ||
                    e.ColumnIndex == retailDataGridViewTextBoxColumn.Index ||
                    e.ColumnIndex == scrapDataGridViewTextBoxColumn.Index ||
                    e.ColumnIndex == profitDataGridViewTextBoxColumn.Index)
                {
                    int type = 0;
                    if (e.ColumnIndex == inDataGridViewTextBoxColumn.Index)
                    {
                        type = CommonInformationTypes.GetCostumeStoreChange4In;
                    }
                    else if (e.ColumnIndex == intoDataGridViewTextBoxColumn.Index)
                    {
                        type = CommonInformationTypes.GetCostumeStoreChange4Into;
                    }
                    else if (e.ColumnIndex == returnDataGridViewTextBoxColumn.Index)
                    {
                        type = CommonInformationTypes.GetCostumeStoreChange4Return;
                    }
                    else if (e.ColumnIndex == turnOutDataGridViewTextBoxColumn.Index)
                    {
                        type = CommonInformationTypes.GetCostumeStoreChange4TurnOut;
                    }
                    else if (e.ColumnIndex == retailDataGridViewTextBoxColumn.Index)
                    {
                        type = CommonInformationTypes.GetCostumeStoreChange4Retail;
                    }
                    else if (e.ColumnIndex == scrapDataGridViewTextBoxColumn.Index)
                    {
                        type = CommonInformationTypes.GetCostumeStoreChange4Scrap;
                    }
                    else if (e.ColumnIndex == profitDataGridViewTextBoxColumn.Index)
                    {
                        type = CommonInformationTypes.GetCostumeStoreChange4Profit;
                    }
                    ShowForm(type, item);
                    //this.DetailClick?.Invoke(type, item, this);
                }
            }
            catch (Exception ee)
            {
                CommonGlobalUtil.ShowError(ee);
            }
        }
예제 #4
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!DataGridViewUtil.CheckPerrmisson(this, sender, e))
            {
                return;
            }
            try
            {
                if (e.RowIndex > -1 && e.ColumnIndex > -1)
                {
                    if (GlobalUtil.EngineUnconnectioned(this))
                    {
                        return;
                    }
                    List <Shop> list = DataGridViewUtil.BindingListToList <Shop>(dataGridView1.DataSource);
                    Shop        item = (Shop)list[e.RowIndex];

                    if (e.ColumnIndex == Column1.Index)
                    {
                        this.SaveClick(item, this);
                    }
                    else if (e.ColumnIndex == ColumnDisable.Index)
                    {
                        if (GlobalMessageBox.Show("确定禁用吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            InteractResult result = GlobalCache.Shop_OnDisable(item.ID);

                            switch (result.ExeResult)
                            {
                            case ExeResult.Success:
                                GlobalMessageBox.Show("禁用成功!");
                                this.dataGridView1.DataSource = null;
                                item.Enabled = false;
                                this.dataGridView1.DataSource = DataGridViewUtil.ListToBindingList(list);
                                break;

                            case ExeResult.Error:
                                GlobalMessageBox.Show(result.Msg);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    else if (e.ColumnIndex == EnabledLink.Index)
                    {
                        if (GlobalMessageBox.Show("确定启用吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            item.Enabled = true;
                            InteractResult result = GlobalCache.ServerProxy.EnableShop(item.ID);

                            switch (result.ExeResult)
                            {
                            case ExeResult.Success:
                                GlobalMessageBox.Show("启用成功!");
                                this.dataGridView1.DataSource = null;
                                item.Enabled = true;
                                this.dataGridView1.DataSource = DataGridViewUtil.ListToBindingList(list);
                                break;

                            case ExeResult.Error:
                                item.Enabled = false;
                                GlobalMessageBox.Show(result.Msg);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    else if (e.ColumnIndex == ColumnDelete.Index)
                    {
                        Delete(item);
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalUtil.ShowError(ex);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }
예제 #5
0
        private DataGridView deepCopyDataGridView()
        {
            DataGridView dgvTmp = new DataGridView();

            dgvTmp.Name = "dgvTmp";
            this.Controls.Add(dgvTmp);
            //  dgvTmp.AllowUserToAddRows = false; //不允许用户生成行,否则导出后会多出最后一行

            dgvTmp.AutoGenerateColumns = false;

            List <RetailDetail> listtb1 = DataGridViewUtil.BindingListToList <RetailDetail>(dataGridView_RetailDetail.DataSource);

            List <RetailDetail> tb2 = new List <RetailDetail>();
            int autoID = 0;

            foreach (RetailDetail idetail in listtb1)
            {
                RetailDetail tDetail = new RetailDetail();
                ReflectionHelper.CopyProperty(idetail, tDetail);
                autoID++;
                tDetail.PrintAutoID = autoID;
                tb2.Add(tDetail);
            }

            DataGridViewTextBoxColumn dgvColumnAuto = new DataGridViewTextBoxColumn();

            dgvColumnAuto.Name             = "序列号";
            dgvColumnAuto.HeaderText       = "序列号";
            dgvColumnAuto.Visible          = true;
            dgvColumnAuto.DataPropertyName = "PrintAutoID";
            dgvTmp.Columns.Add(dgvColumnAuto);

            List <DataGridViewTextBoxColumn> listColumns = new List <DataGridViewTextBoxColumn>();

            for (int i = 0; i < dataGridView_RetailDetail.Columns.Count; i++)
            {
                dgvTmp.Columns.Add(dataGridView_RetailDetail.Columns[i].Name, dataGridView_RetailDetail.Columns[i].HeaderText);
                if (dataGridView_RetailDetail.Columns[i].DefaultCellStyle.Format.Contains("N")) //使导出Excel文档金额列可做SUM运算
                {
                    dgvTmp.Columns[i + 1].DefaultCellStyle.Format = dataGridView_RetailDetail.Columns[i].DefaultCellStyle.Format;
                }
                if (!dataGridView_RetailDetail.Columns[i].Visible)
                {
                    dgvTmp.Columns[i + 1].Visible = false;
                }
                dgvTmp.Columns[i + 1].DataPropertyName = dataGridView_RetailDetail.Columns[i].DataPropertyName;
                if (dataGridView_RetailDetail.Columns[i].HeaderText == "单价")
                {
                    dgvTmp.Columns[i + 1].HeaderText = "吊牌价";
                }
                else if (dataGridView_RetailDetail.Columns[i].HeaderText == "销售额")
                {
                    dgvTmp.Columns[i + 1].HeaderText = "金额";
                }
                else
                {
                    dgvTmp.Columns[i + 1].HeaderText = dataGridView_RetailDetail.Columns[i].HeaderText;
                }
                dgvTmp.Columns[i + 1].Tag  = dataGridView_RetailDetail.Columns[i].Tag;
                dgvTmp.Columns[i + 1].Name = dataGridView_RetailDetail.Columns[i].Name;
            }
            dgvTmp.DataSource = tb2;


            return(dgvTmp);
        }
예제 #6
0
        private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }
            DataGridView dataGridView = (DataGridView)sender;

            try
            {
                //检查现有的列表是否有重复名称
                List <SizeGroup> sizeGroups = DataGridViewUtil.BindingListToList <SizeGroup>(dataGridView1.DataSource);
                SizeGroup        group      = dataGridView1.Rows[e.RowIndex].DataBoundItem as SizeGroup;
                if (e.ColumnIndex == sizeGroupNameDataGridViewTextBoxColumn.Index)
                {
                    if (e.FormattedValue == null || String.IsNullOrEmpty(e.FormattedValue.ToString()))
                    {
                        GlobalMessageBox.Show("尺码组名称不能为空!");
                        dataGridView.CancelEdit();
                        return;
                    }
                    if (sizeGroups != null)
                    {
                        int index = sizeGroups.FindIndex(t => e.FormattedValue?.ToString() == t.ShowName);
                        if (e.RowIndex != index)
                        {
                            if (index > -1)
                            {
                                GlobalMessageBox.Show("尺码组名称已存在!");
                                dataGridView.CancelEdit();
                                return;
                            }
                        }
                    }
                }
                else if (e.ColumnIndex >= nameOfFDataGridViewTextBoxColumn.Index && e.ColumnIndex <= nameOfXL6DataGridViewTextBoxColumn.Index)
                {
                    if (e.FormattedValue == null || String.IsNullOrEmpty(e.FormattedValue.ToString()))
                    {
                        GlobalMessageBox.Show("尺码名称不能为空!");
                        dataGridView.CancelEdit();
                        return;
                    }
                    else
                    {
                        //不能重复
                        string currertKeyValue = e.FormattedValue.ToString();
                        //排除这一个单元格的判断
                        foreach (SizeGroup sizeGroup in sizeGroups)
                        {
                            bool checkBool = false;
                            //如果是同一个group,那么只检查不是同个属性的值
                            if (group == sizeGroup)
                            {
                                if (e.ColumnIndex != nameOfFDataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfF == currertKeyValue;
                                }
                                if (e.ColumnIndex != nameOfXSDataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfXS == currertKeyValue;
                                }
                                if (e.ColumnIndex != nameOfSDataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfS == currertKeyValue;
                                }
                                if (e.ColumnIndex != nameOfMDataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfM == currertKeyValue;
                                }
                                if (e.ColumnIndex != nameOfLDataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfL == currertKeyValue;
                                }
                                if (e.ColumnIndex != nameOfXLDataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfXL == currertKeyValue;
                                }
                                if (e.ColumnIndex != nameOfXL2DataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfXL2 == currertKeyValue;
                                }
                                if (e.ColumnIndex != nameOfXL3DataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfXL3 == currertKeyValue;
                                }
                                if (e.ColumnIndex != nameOfXL4DataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfXL4 == currertKeyValue;
                                }
                                if (e.ColumnIndex != nameOfXL5DataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfXL5 == currertKeyValue;
                                }
                                if (e.ColumnIndex != nameOfXL6DataGridViewTextBoxColumn.Index)
                                {
                                    checkBool = checkBool || sizeGroup.NameOfXL6 == currertKeyValue;
                                }
                            }
                            else
                            {
                                //不是同一个GROUP,那么检查所有字段
                                checkBool = sizeGroup.NameOfF == currertKeyValue ||
                                            sizeGroup.NameOfS == currertKeyValue ||
                                            sizeGroup.NameOfM == currertKeyValue ||
                                            sizeGroup.NameOfL == currertKeyValue ||
                                            sizeGroup.NameOfXL == currertKeyValue ||
                                            sizeGroup.NameOfXL2 == currertKeyValue ||
                                            sizeGroup.NameOfXL3 == currertKeyValue ||
                                            sizeGroup.NameOfXL4 == currertKeyValue ||
                                            sizeGroup.NameOfXL5 == currertKeyValue ||
                                            sizeGroup.NameOfXL6 == currertKeyValue;
                            }

                            if (checkBool)
                            {
                                GlobalMessageBox.Show("尺码名称已存在!");
                                dataGridView.CancelEdit();
                                return;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                GlobalMessageBox.Show("输入格式错误!");
                dataGridView.CancelEdit();
            }
        }
예제 #7
0
        private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!DataGridViewUtil.CheckPerrmisson(this, sender, e))
            {
                return;
            }
            try
            {
                if (e.RowIndex > -1 && e.ColumnIndex > -1)
                {
                    List <Guide> list = DataGridViewUtil.BindingListToList <Guide>(this.dataGridView.DataSource);
                    Guide        item = (Guide)list[e.RowIndex];
                    if (e.ColumnIndex == Column12.Index)
                    {
                        this.AddClick(item, this);
                    }
                    else if (e.ColumnIndex == Column5.Index)
                    {
                        this.ChangePwdClick(item, this);
                    }
                    switch (this.dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value)
                    {
                    //case "修改":

                    //    this.AddClick(item,this);


                    //    break;
                    //    case "修改密码":

                    //        this.ChangePwdClick(item,this);


                    //break;
                    case "删除":
                        if (GlobalMessageBox.Show("确定删除吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            DeleteResult result = GlobalCache.GuideList_OnDelete(item.ID);
                            if (result == DeleteResult.Error)
                            {
                                GlobalMessageBox.Show("内部错误!");
                                return;
                            }
                            else
                            {
                                GlobalMessageBox.Show("删除成功!");

                                this.dataGridView.DataSource = null;
                                list.Remove(item);
                                this.dataGridView.DataSource = DataGridViewUtil.ListToBindingList(list);
                            }
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalUtil.ShowError(ex);
            }
        }