示例#1
0
        public void Click1()
        {
            int           i      = 0;
            OrderT        order1 = new OrderT();
            OrderC        oc     = new OrderC();
            MingXi        mx     = new MingXi();
            List <OrderC> olist  = new List <OrderC>();

            order1.OrdetType(odType);
            odType = order1.Quexian;//订单类型
            string batch   = txtbatch.Text.Trim().ToString();
            string orderno = textBox1.Text.ToString();
            string matnr   = textBox2.Text.ToString();
            string mold    = textBox3.Text.ToString();

            string[] splitStrings = txtDate.Text.Split();
            string   datestr = string.Join("", splitStrings);
            DateTime date = Convert.ToDateTime(datestr);
            string   jitai1 = txtjitai1.Text.Trim();
            string   jitai2 = txtjitai2.Text.Trim();
            string   jitai3 = txtjitai3.Text.Trim();
            string   jitai4 = txtjitai4.Text.Trim();
            string   jitai5 = txtjitai5.Text.Trim();
            string   jitai6 = txtjitai6.Text.Trim();
            string   jitai7 = txtjitai7.Text.Trim();
            string   jitai8 = txtjitai8.Text.Trim();
            string   caozuo1 = txtcz1.Text.Trim();
            string   caozuo2 = txtcz2.Text.Trim();
            string   caozuo3 = txtcz3.Text.Trim();
            string   caozuo4 = txtcz4.Text.Trim();
            string   caozuo5 = txtcz5.Text.Trim();
            string   caozuo6 = txtcz6.Text.Trim();
            string   caozuo7 = txtcz7.Text.Trim();
            string   caozuo8 = txtcz8.Text.Trim();
            int      chanliang1 = int.Parse(txtcl1.Text.Trim());
            int      chanliang2 = int.Parse(txtcl2.Text.Trim());
            int      chanliang3 = int.Parse(txtcl3.Text.Trim());
            int      chanliang4 = int.Parse(txtcl4.Text.Trim());
            int      chanliang5 = int.Parse(txtcl5.Text.Trim());
            int      chanliang6 = int.Parse(txtcl6.Text.Trim());
            int      chanliang7 = int.Parse(txtcl7.Text.Trim());
            int      chanliang8 = int.Parse(txtcl8.Text.Trim());
            int      banhao = int.Parse(str2.Substring(8, 1));
            float    gongshi = float.Parse(txtgh.Text.Trim());
            int      bl1, bl2, bl3, bl4, bl5, bl6, bl7, bl8, intqx1, intqx2, intqx3, intqx4, intqx5, intqx6, intqx7, intqx8;

            int.TryParse(buliang1.Text.Trim().ToString(), out bl1);
            int.TryParse(buliang2.Text.Trim().ToString(), out bl2);
            int.TryParse(buliang3.Text.Trim().ToString(), out bl3);
            int.TryParse(buliang4.Text.Trim().ToString(), out bl4);
            int.TryParse(buliang5.Text.Trim().ToString(), out bl5);
            int.TryParse(buliang6.Text.Trim().ToString(), out bl6);
            int.TryParse(buliang7.Text.Trim().ToString(), out bl7);
            int.TryParse(buliang8.Text.Trim().ToString(), out bl8);
            int.TryParse(quexian1.Text.Trim().ToString(), out intqx1);
            int.TryParse(quexian2.Text.Trim().ToString(), out intqx2);
            int.TryParse(quexian3.Text.Trim().ToString(), out intqx3);
            int.TryParse(quexian4.Text.Trim().ToString(), out intqx4);
            int.TryParse(quexian5.Text.Trim().ToString(), out intqx5);
            int.TryParse(quexian6.Text.Trim().ToString(), out intqx6);
            int.TryParse(quexian7.Text.Trim().ToString(), out intqx7);
            int.TryParse(quexian8.Text.Trim().ToString(), out intqx8);
            int[]    bl         = new int[] { bl1, bl2, bl3, bl4, bl5, bl6, bl7, bl8 };
            int[]    intqx      = new int[] { intqx1, intqx2, intqx3, intqx4, intqx5, intqx6, intqx7, intqx8 };
            string[] jitai      = new string[] { jitai1, jitai2, jitai3, jitai4, jitai5, jitai6, jitai7, jitai8 };
            string[] caozuo     = new string[] { caozuo1, caozuo2, caozuo3, caozuo4, caozuo5, caozuo6, caozuo7, caozuo8 };
            int[]    changliang = new int[] { chanliang1, chanliang2, chanliang3, chanliang4, chanliang5, chanliang6, chanliang7, chanliang8 };
            string[] strqx      = new string[8];
            int      mid        = 0;
            bool     x          = true; //判断是否添加数据到数据库

            string        sql    = string.Format("select QueXian,Number from Class_Table where Qclass='{0}'", odType);
            SqlDataReader reader = SqlDB.ExecuteReader(sql);

            while (reader.Read())
            {
                oc = new OrderC()
                {
                    Quexian = reader.GetString(0), Number = reader.GetInt32(1)
                };
                olist.Add(oc);
                i++;
            }
            reader.Dispose();//关闭
            sql    = string.Format("select max(ID) from Master");
            reader = SqlDB.ExecuteReader(sql);
            while (reader.Read())
            {
                mid = reader.GetInt32(0) + 1;
                break;
            }
            reader.Dispose();//关闭
            for (int j = 0; j < 8; j++)
            {
                if (bl[j] == 0 || jitai[j].Length == 0)
                {
                    break;
                }
                if (olist.Count > 0)
                {
                    strqx[j] = mx.PiDui(intqx[j], olist);
                    if (strqx[j].Length == 0)
                    {
                        MessageBox.Show("没有找到" + intqx[j] + "所对应的缺陷", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        x = false;
                    }
                    else
                    {
                        sql = string.Format("insert into QueXIanNo(Number1,QueXian,MasterID,Number2,P_No,Number3) values({0},'{1}','{2}','{3}','{4}',{5})", bl[j], strqx[j], mid, jitai[j], caozuo[j], changliang[j]);
                        SqlDB.ExecuteNonQuery(sql);   //添加明细表信息 QueXianNo
                    }
                }
                else
                {
                    x = false;
                }
            }
            if (x == true)
            {
                DateTime nowdate = DateTime.Now;
                sql = string.Format("insert into Master(Batch,OrderNo,Matnr,Mold,Date,B_No,Time,Date2,OType) values('{0}','{1}','{2}','{3}','{4}',{5},{6},'{7}','{8}')", batch, orderno, matnr, mold, date, banhao, gongshi, nowdate, odType);
                SqlDB.ExecuteNonQuery(sql);   //添加抬头表信息 Master
            }
        }
示例#2
0
        public JsonResult addmingxi(MingXi m)
        {
            var we = d.Add(m);

            return(Json(we, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public int Add(MingXi m)
        {
            string sql = $"insert into MingXi values ('{m.Mname}','{m.Mgg}','{m.Mtime}','{m.Gid}','{m.Sctime}','{m.Yxtime}','{m.Mcount}','{m.Mprice}')";

            return(db.ExecuteNonQuery(sql));
        }