コード例 #1
0
        private void btn_update_Click(object sender, EventArgs e)
        {
            CommoditySize commoditySize = new CommoditySize();

            commoditySize.ITEMNO   = txt_code.Text;
            commoditySize.ITEMNAME = txt_name.Text;
            try
            {
                commoditySize.ILENGTH = Convert.ToDecimal(txt_lenght.Text);
                commoditySize.IWIDTH  = Convert.ToDecimal(txt_weight.Text);
                commoditySize.IHEIGHT = Convert.ToDecimal(txt_height.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("请输入正确格式的长、宽、高!");
                return;
            }
            switch (comboBox_cdtype.SelectedIndex)
            {
            case 0:
                commoditySize.CDTYPE = 0;
                break;

            case 1:
                commoditySize.CDTYPE = 1;
                break;

            default:
                commoditySize.CDTYPE = 0;
                break;
            }
            switch (comboBox_doubletask.SelectedIndex)
            {
            case 0:
                commoditySize.DOUBLETAKE = "0";
                break;

            case 1:
                commoditySize.DOUBLETAKE = "1";
                break;

            default:
                commoditySize.DOUBLETAKE = "";
                break;
            }
            DialogResult result = MessageBox.Show("确认修改" + commoditySize.ITEMNAME + "的尺寸信息?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Cancel)
            {
                return;
            }
            string str = FmCommoditySizeFun.UpdateCommodity(commoditySize) == true ? "更新成功!" : "更新失败!";

            MessageBox.Show(str);
            databinging();
        }
コード例 #2
0
        /// <summary>
        /// 修改尺寸
        /// </summary>
        /// <param name="commodity">商品</param>
        /// <returns></returns>
        public static bool UpdateCommodity(CommoditySize commodity)
        {
            using (Entities et = new Entities())
            {
                var commoditys = et.T_WMS_ITEM.Where(x => x.ITEMNO == commodity.ITEMNO).Select(x => x).FirstOrDefault();
                commoditys.IHEIGHT    = commodity.IHEIGHT;
                commoditys.ILENGTH    = commodity.ILENGTH;
                commoditys.ITEMNAME   = commodity.ITEMNAME;
                commoditys.IWIDTH     = commodity.IWIDTH;
                commoditys.DOUBLETAKE = commodity.DOUBLETAKE;
                commoditys.CDTYPE     = commodity.CDTYPE;
                int res = et.SaveChanges();

                return(res > 0 ? true : false);;
            }
        }