Exemplo n.º 1
0
        private static Queue <Statement> generateDressQueue(DressDefinition dress)
        {
            Queue <Statement> sqls = new Queue <Statement>();
            Statement         sql  = new Statement("insert into dressDefinition(wd_id,wd_date,wd_big_category,wd_litter_category,wd_factory,wd_color,memo,emergency_period,normal_period,is_renew,settlementPrice,attribute) values('" + dress.wd_id + "','" + dress.wd_date + "','" + dress.wd_big_category + "','" + dress.wd_litter_category + "','" + dress.wd_factory + "','" + dress.wd_color + "','" + dress.memo + "','" + dress.emergency_period + "','" + dress.normal_period + "','" + dress.is_renew + "'," + dress.settlementPrice.ToString() + "," + dress.attribute + ")");

            sqls.Enqueue(sql);

            for (int i = 0; i < dress.wdscs.Length; i++)
            {
                WeddingDressSizeAndCount wdsc = dress.wdscs[i];
                sql = new Statement("insert into dress(wd_id, wd_size, wd_price,  wd_listing_date, wd_count, storeId) values('" + dress.wd_id + "', '" + wdsc.wd_size + "', '" + wdsc.wd_price + "', '" + wdsc.wd_listing_date + "', " + wdsc.wd_count + ", " + Sharevariables.StoreId + ")");
                sqls.Enqueue(sql);
            }

            for (int i = 1; i <= dress.pictures.Count; i++)
            {
                byte[] image     = dress.pictures[i];
                byte[] thumbnail = dress.thumbnails[i];
                sql     = new Statement();
                sql.Sql = "insert into dressImage(wd_id,pic_id,pic_img,thumbnail) values('" + dress.wd_id + "'," + i + ",@pic_img,@thumbnail)";
                SqlParameter parameter = new SqlParameter("@pic_img", SqlDbType.Image);
                parameter.Value = image;
                List <SqlParameter> parameters = new List <SqlParameter>();
                parameters.Add(parameter);
                parameter       = new SqlParameter("thumbnail", SqlDbType.Image);
                parameter.Value = thumbnail;
                parameters.Add(parameter);
                sql.Paremeters = parameters;
                sqls.Enqueue(sql);
            }
            return(sqls);
        }
Exemplo n.º 2
0
        private void retrieve(string wd_id)
        {
            Data dressProperties = ShardDb.getDressDefinitionById(wd_id);

            if (!dressProperties.Success)
            {
                this.Close();
                return;
            }
            DataRow row = dressProperties.DataTable.Rows[0];

            dress.wd_id              = wd_id;
            dress.wd_date            = row.ItemArray[0].ToString();
            dress.wd_big_category    = row.ItemArray[1].ToString();
            dress.wd_litter_category = row.ItemArray[2].ToString();
            dress.wd_factory         = row.ItemArray[3].ToString();
            dress.wd_color           = row.ItemArray[4].ToString();
            dress.attribute          = Convert.ToInt32(row.ItemArray[5]);
            dress.memo             = row.ItemArray[6].ToString();
            dress.emergency_period = row.ItemArray[7].ToString();
            dress.normal_period    = row.ItemArray[8].ToString();
            dress.is_renew         = row.ItemArray[9].ToString();
            dress.settlementPrice  = (row.ItemArray[10] == DBNull.Value) ? 0 : decimal.Parse(row.ItemArray[10].ToString());

            Data dressSizeAndNumbers = ShardDb.getDressById(wd_id);

            if (!dressProperties.Success)
            {
                this.Close();
                return;
            }
            WeddingDressSizeAndCount[] wdscs = new WeddingDressSizeAndCount[7];
            DataRowCollection          rows  = dressSizeAndNumbers.DataTable.Rows;

            for (int i = 0; i < rows.Count; i++)
            {
                WeddingDressSizeAndCount wdsc = new WeddingDressSizeAndCount();
                wdsc.wd_id           = wd_id;
                wdsc.id              = rows[i].ItemArray[0].ToString();
                wdsc.wd_size         = rows[i].ItemArray[1].ToString();
                wdsc.wd_price        = decimal.Parse(rows[i].ItemArray[2].ToString());
                wdsc.wd_listing_date = rows[i].ItemArray[3].ToString();
                wdsc.wd_count        = Convert.ToInt16(rows[i].ItemArray[4]);
                wdsc.store_id        = Convert.ToInt16(rows[i].ItemArray[5]);
                wdscs[i]             = wdsc;
            }
            dress.wdscs = wdscs;

            Data imagedata = ShardDb.getImagesByDressId(wd_id);

            if (!dressProperties.Success)
            {
                this.Close();
                return;
            }
            Dictionary <int, byte[]> pictures   = new Dictionary <int, byte[]>();
            Dictionary <int, byte[]> thumbnails = new Dictionary <int, byte[]>();

            foreach (DataRow dataRow in imagedata.DataTable.Rows)
            {
                pictures.Add(Convert.ToInt16(dataRow.ItemArray[1]), (byte[])dataRow.ItemArray[2]);
                thumbnails.Add(Convert.ToInt16(dataRow.ItemArray[1]), (byte[])dataRow.ItemArray[3]);
            }
            dress.pictures   = pictures;
            dress.thumbnails = thumbnails;

            //show to controls
            textBoxId.Text                  = dress.wd_id;
            wd_date.Value                   = DateTime.Parse(dress.wd_date);
            wd_color.SelectedItem           = dress.wd_color;
            wd_factory.SelectedItem         = dress.wd_factory;
            wd_big_category.SelectedItem    = dress.wd_big_category;
            wd_litter_category.SelectedItem = dress.wd_litter_category;
            cb_is_renew.SelectedItem        = dress.is_renew;
            tb_normal_period.Text           = dress.normal_period;
            tb_emergency_period.Text        = dress.emergency_period;
            memo.Text = dress.memo;
            textBoxSettlementPrice.Text = dress.settlementPrice.ToString();
            textBoxPrice.Text           = "";
            foreach (int key in attributes.Keys)
            {
                if ((key & dress.attribute) != 0)
                {
                    attributes[key].Checked = true;
                }
            }
            for (int i = 0; i < 7; i++)
            {
                WeddingDressSizeAndCount dressInstance = dress.wdscs[i];
                prices[i].Text        = dressInstance.wd_price.ToString();
                publishDates[i].Value = DateTime.Parse(dressInstance.wd_listing_date);
                counts[i].Text        = dressInstance.wd_count.ToString();
            }

            showThumbnail();
        }
Exemplo n.º 3
0
        private bool validate()
        {
            if (textBoxId.Text.Trim().Length == 0)
            {
                MessageBox.Show("商品编号不能为空!");
                textBoxId.Focus();
                return(false);
            }
            if (!isUpdate)
            {
                Data dressIds = ShardDb.getWeddingDressIds(textBoxId.Text.Trim());
                if (dressIds.DataTable.Rows.Count > 0)
                {
                    MessageBox.Show("商品编号已存在,请输入新编号!");
                    textBoxId.Focus();
                    return(false);
                }
            }
            decimal price = 0;

            foreach (TextBox textBox in prices)
            {
                if (!decimal.TryParse(textBox.Text.Trim(), out price))
                {
                    MessageBox.Show("商品价格格式错误!");
                    textBox.Focus();
                    return(false);
                }
            }
            decimal settlementPrice = 0;

            if (!decimal.TryParse(textBoxSettlementPrice.Text.Trim(), out settlementPrice))
            {
                MessageBox.Show("商品结算价格格式错误!");
                textBoxPrice.Focus();
                return(false);
            }
            if (pictureBox1.Image == null)
            {
                MessageBox.Show("请至少加入一张图片!");
                pictureBox1.Focus();
                return(false);
            }
            dress.wd_id              = textBoxId.Text.Trim();
            dress.wd_big_category    = wd_big_category.Text.Trim();
            dress.wd_litter_category = wd_litter_category.Text.Trim();
            dress.wd_date            = wd_date.Text.Trim();
            dress.wd_factory         = wd_factory.Text.Trim();
            dress.is_renew           = cb_is_renew.Text.Trim();
            dress.emergency_period   = tb_emergency_period.Text.Trim();
            dress.memo            = memo.Text.Trim();
            dress.normal_period   = tb_normal_period.Text.Trim();
            dress.wd_color        = wd_color.Text.Trim();
            dress.settlementPrice = settlementPrice;
            dress.attribute       = 0;
            foreach (int key in attributes.Keys)
            {
                if (attributes[key].Checked)
                {
                    dress.attribute += key;
                }
            }

            WeddingDressSizeAndCount[] dressInstances = new WeddingDressSizeAndCount[7];
            WeddingDressSizeAndCount   dressInstance  = new WeddingDressSizeAndCount();

            dressInstance.wd_id           = dress.wd_id;
            dressInstance.wd_size         = "XS";
            dressInstance.wd_count        = Convert.ToInt16(tb_xs_sl.Text.Trim());
            dressInstance.wd_price        = decimal.Parse(tb_xs_jg.Text.Trim());
            dressInstance.wd_listing_date = dt_xs_sssj.Text.Trim();
            dressInstances[0]             = dressInstance;

            dressInstance                 = new WeddingDressSizeAndCount();
            dressInstance.wd_id           = dress.wd_id;
            dressInstance.wd_size         = "S";
            dressInstance.wd_count        = Convert.ToInt16(tb_s_sl.Text.Trim());
            dressInstance.wd_price        = decimal.Parse(tb_s_jg.Text.Trim());
            dressInstance.wd_listing_date = dt_s_sssj.Text.Trim();
            dressInstances[1]             = dressInstance;

            dressInstance                 = new WeddingDressSizeAndCount();
            dressInstance.wd_id           = dress.wd_id;
            dressInstance.wd_size         = "M";
            dressInstance.wd_count        = Convert.ToInt16(tb_m_sl.Text.Trim());
            dressInstance.wd_price        = decimal.Parse(tb_m_jg.Text.Trim());
            dressInstance.wd_listing_date = dt_m_sssj.Text.Trim();
            dressInstances[2]             = dressInstance;

            dressInstance                 = new WeddingDressSizeAndCount();
            dressInstance.wd_id           = dress.wd_id;
            dressInstance.wd_size         = "L";
            dressInstance.wd_count        = Convert.ToInt16(tb_l_sl.Text.Trim());
            dressInstance.wd_price        = decimal.Parse(tb_l_jg.Text.Trim());
            dressInstance.wd_listing_date = dt_l_sssj.Text.Trim();
            dressInstances[3]             = dressInstance;

            dressInstance                 = new WeddingDressSizeAndCount();
            dressInstance.wd_id           = dress.wd_id;
            dressInstance.wd_size         = "XL";
            dressInstance.wd_count        = Convert.ToInt16(tb_xl_sl.Text.Trim());
            dressInstance.wd_price        = decimal.Parse(tb_xl_jg.Text.Trim());
            dressInstance.wd_listing_date = dt_xl_sssj.Text.Trim();
            dressInstances[4]             = dressInstance;

            dressInstance                 = new WeddingDressSizeAndCount();
            dressInstance.wd_id           = dress.wd_id;
            dressInstance.wd_size         = "XXL";
            dressInstance.wd_count        = Convert.ToInt16(tb_xxl_sl.Text.Trim());
            dressInstance.wd_price        = decimal.Parse(tb_xxl_jg.Text.Trim());
            dressInstance.wd_listing_date = dt_xxl_sssj.Text.Trim();
            dressInstances[5]             = dressInstance;

            dressInstance                 = new WeddingDressSizeAndCount();
            dressInstance.wd_id           = dress.wd_id;
            dressInstance.wd_size         = "LSDZ";
            dressInstance.wd_count        = Convert.ToInt16(tb_lsdz_sl.Text.Trim());
            dressInstance.wd_price        = decimal.Parse(tb_lsdz_jg.Text.Trim());
            dressInstance.wd_listing_date = dt_lsdz_sssj.Text.Trim();
            dressInstances[6]             = dressInstance;

            dress.wdscs = dressInstances;

            return(true);
        }