Exemplo n.º 1
0
        private void SaveSettings(CancelEventArgs e)
        {
            Product.ProductName = txtProductName.Text;
            Product.MailTitle   = txtMailTitle.Text;
            Product.Disable     = cbDisable.Checked;
            Product.MailContent = txtMailContent.Text.Replace(System.Environment.NewLine, "\n");
            Product.IsCredit    = rbCreditYes.Checked ? true : false;
            Product.IsDelay     = rbWaitSpecific.Checked ? true : false;
            if (rbWaitSpecific.Checked)
            {
                Product.DelaySeconds = int.Parse(numWaitSeconds.Value.ToString());
            }
            else
            {
                Product.DelaySeconds = null;
            }

            DialogResult dr = MessageBox.Show("确定提交修改?", "确定", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                if (ProductID <= 0)    // 新增
                {
                    try
                    {
                        ProductStorage.AddProduct(Product);
                        MessageBox.Show("产品增加完成");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else  // 修改
                {
                    try
                    {
                        ProductStorage.UpdateProduct(Product);
                        MessageBox.Show("产品修改完成");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 编辑-删除产品
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuEditProductDel_Click(object sender, EventArgs e)
        {
            if (lvProductList.SelectedItems.Count > 0)
            {
                Product product = (Product)lvProductList.SelectedItems[0].Tag;

                DialogResult dr = MessageBox.Show(string.Format(@"确定删除产品[{0}]?", product.ProductName), "确定", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    try
                    {
                        ProductStorage.DeleteProduct(product);
                        MessageBox.Show("产品已删除!");
                        ReloadProductList();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化列表
        /// </summary>
        private void DisplayProductList()
        {
            DateTime date = DateTime.Now.Date;

            if (rbDateToday.Checked)
            {
                date = DateTime.Now.Date;
            }
            else if (rbDateOther.Checked)
            {
                date = dtpDate.Value.Date;
            }
            // 初始化前先更新一遍状态
            ProductStorage.UpdateProductListOKFlag(Manager.ProductList, date);


            lvProductList.Items.Clear();
            lvProductList.BeginUpdate();
            int idx = 0;    // 计数器

            foreach (Product product in Manager.ProductList)
            {
                if (cbShowNoCreditOnly.Checked)
                {
                    if (product.IsCredit)
                    {
                        continue;
                    }
                }

                ListViewItem lvi = new ListViewItem((++idx).ToString());
                lvi.SubItems.Add(product.ProductName);
                lvi.SubItems.Add(product.IsCredit ? "√" : string.Empty);
                lvi.SubItems.Add("×");
                lvi.SubItems.Add(product.IsSendOK ? "√" : "×");
                lvi.SubItems.Add(string.Empty);

                lvi.Tag = product;
                //lvi.Checked = true;

                if (product.IsSendOK)
                {
                    lvi.BackColor = SystemColors.Window;
                }
                else
                {
                    lvi.BackColor = Color.Pink;
                }

                lvProductList.Items.Add(lvi);
            }

            //lvProductList.Columns[0].Width = -1;
            //lvProductList.Columns[1].Width = -1;
            //lvProductList.Columns[2].Width = -1;
            //lvProductList.Columns[3].Width = -1;
            //lvProductList.Columns[4].Width = -1;
            //lvProductList.Columns[5].Width = -1;

            lvProductList.EndUpdate();

            lbIsAllSendOK.Text      = "N/A";
            lbIsAllSendOK.ForeColor = Color.Black;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 重置整个产品
        /// </summary>
        protected override void ResetDialog()
        {
            Product product;

            if (ProductID <= 0)
            {
                product = new Product(
                    id: 0,
                    productName: string.Empty,
                    mailTitle: string.Empty,
                    mailContent: string.Empty,
                    disable: false,
                    attachmentList: new ProductAttachmentList(),
                    receiverList: new ProductReceiverList(),
                    isCredit: false,
                    isDelay: false,
                    delaySeconds: null);
            }
            else
            {
                product = ProductStorage.ReadProduct(ProductID);
            }
            _product = product;

            // 总体参数
            txtProductName.Text = Product.ProductName;
            txtMailTitle.Text   = Product.MailTitle;
            txtMailContent.Text = Product.MailContent.Replace("\n", System.Environment.NewLine);
            cbDisable.Checked   = Product.Disable;
            if (Product.IsCredit)
            {
                rbCreditYes.Checked = true;
            }
            else
            {
                rbCreditNo.Checked = true;
            }
            if (Product.IsDelay == false)
            {
                rbWaitGlobal.Checked = true;
            }
            else
            {
                rbWaitSpecific.Checked = true;
                numWaitSeconds.Value   = Product.DelaySeconds.HasValue ? Product.DelaySeconds.Value : 0;
            }


            // 附件
            ResetAttachmentList();
            // 收件人
            ResetReceiverList();

            if (Product.Id <= 0)
            {
                this.Text = "新增产品发送参数";
            }
            else
            {
                this.Text = "修改产品发送参数";
            }
        }
Exemplo n.º 5
0
 public void ReloadProductList()
 {
     _productList = ProductStorage.ReadProductlist();     // 读取产品信息
 }
Exemplo n.º 6
0
        public static ProductSendLogList ReadSendLogList(DateTime dtBegin, DateTime dtEnd)
        {
            ProductSendLogList sendLogList = new ProductSendLogList();

            // 临时键值对,存放产品id-产品名称
            Dictionary <int, string> dicProduct = new Dictionary <int, string>();

            try
            {
                using (SQLiteConnection cn = new SQLiteConnection(ConfigurationManager.AppSettings["conn"]))
                {
                    cn.Open();

                    using (SQLiteCommand cmd = new SQLiteCommand(cn))
                    {
                        cmd.CommandText = "select * from ProductSendLog where ProductDate between @Begin and @End";
                        cmd.Parameters.Add(new SQLiteParameter("@Begin", dtBegin));
                        cmd.Parameters.Add(new SQLiteParameter("@End", dtEnd));

                        using (SQLiteDataReader dr = cmd.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                // 获取产品基本信息
                                int id        = int.Parse(dr["ID"].ToString());
                                int productID = int.Parse(dr["ProductID"].ToString());

                                // 获取产品名称
                                string productName = string.Empty;
                                if (dicProduct.ContainsKey(productID))
                                {
                                    productName = dicProduct[productID];
                                }
                                else
                                {
                                    productName = ProductStorage.GetProductNameById(productID, cn);
                                    dicProduct.Add(productID, productName);
                                }
                                DateTime productDate = DateTime.Parse(dr["ProductDate"].ToString());
                                bool     isSendOK    = bool.Parse(dr["IsSendOK"].ToString());
                                string   note        = dr["Note"].ToString();
                                DateTime opTime      = DateTime.Parse(dr["OpTime"].ToString());


                                ProductSendLog sendLog = new ProductSendLog(
                                    id,
                                    productID,
                                    productName,
                                    productDate,
                                    isSendOK,
                                    note,
                                    opTime
                                    );

                                sendLogList.Add(sendLog);
                            } //eof while
                        }     //eof dr
                    }         //eof cmd
                }             //eof conn
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                dicProduct.Clear();
            }

            return(sendLogList);
        }