Exemplo n.º 1
0
        protected void btnAddRcd_Click(object sender, EventArgs e)
        {
            this.txtID.Focus();
            if (this.txtID.Text.Trim() == "")
            {
                Methods.AjaxMessageBox(this, "产品序列号不能为空!"); return;
            }

            int rc = Methods.getModelIDCount(this.txtID.Text.Trim());

            if (rc > 0)
            {
                Methods.AjaxMessageBox(this, "此产品序列号已经存在!"); return;
            }
            else if (rc < 0)
            {
                Methods.AjaxMessageBox(this, "查询产品序列号时出现异常,详情请查看日志!"); return;
            }

            ds = (DataSet)ViewState["tmpds"];
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (this.txtID.Text.Trim() == ds.Tables[0].Rows[i]["ID"].ToString())
                {
                    Methods.AjaxMessageBox(this, "此产品序列号已经存在!"); return;
                }
            }

            int Len = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["MIDLenInSN"]);

            if (this.txtID.Text.Trim().Length <= Len)
            {
                Methods.AjaxMessageBox(this, "此产品序列号长度必须" + Len + "位以上!"); return;
            }

            DataRow r           = ds.Tables[0].NewRow();//将数据源添加一新行
            Guid    gd          = Guid.NewGuid();
            string  sn          = gd.ToString();
            string  PlanID      = "";
            int     ProcedureID = -1;
            string  ModelID     = Methods.GetPlanPIDByEID(SessionUser.ID, out PlanID);



            string mid = this.txtID.Text.Trim().Substring(0, Len);

            //if(mid!=ModelID)
            //{
            //        Methods.AjaxMessageBox(this,"序列号对应的品号与计划中的品号不一致!"); return;
            //}
            WSProcedureCtrl.ProcedureCtrl pctrl = new ProcedureCtrl();
            if (!pctrl.CheckModel(mid, SessionUser.ID, 0))
            {
                Methods.AjaxMessageBox(this, "序列号对应的品号与计划中的品号不一致!"); return;
            }


            ProcedureID = Convert.ToInt32(Methods.GetProcIDByMID(mid, PlanID));//
            if (ProcedureID < 0)
            {
                Methods.AjaxMessageBox(this, "提示:没有对应的产品流程号!");
            }

            r["ID"]          = this.txtID.Text.Trim();
            r["SN"]          = sn;//GUID
            r["ModelID"]     = mid;
            r["PlanID"]      = PlanID;
            r["ProcedureID"] = ProcedureID;
            r["FoundTime"]   = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd");
            r["Remark"]      = "";

            ds.Tables[0].Rows.InsertAt(r, 0);
            ds.AcceptChanges();

            this.GridView1.DataSource = ds;
            this.GridView1.DataBind();

            this.txtID.Text = "";
        }
Exemplo n.º 2
0
        protected void btnAddRcd_Click(object sender, EventArgs e)
        {
            if (this.txtID.Text.Trim() == "")
            {
                Methods.AjaxMessageBox(this, "序列号不能为空!"); return;
            }

            int rc = Methods.getModelIDCount(this.txtID.Text.Trim());

            if (rc == 0)
            {
                Methods.AjaxMessageBox(this, "此序列号在数据库中不存在!"); return;
            }
            else if (rc < 0)
            {
                Methods.AjaxMessageBox(this, "查询产品序列号时出现异常,详情请查看日志!"); return;
            }

            int Len = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["MIDLenInSN"]);

            if (this.txtID.Text.Trim().Length <= Len)
            {
                Methods.AjaxMessageBox(this, "此序列号长度必须" + Len + "位以上!"); return;
            }

            string mid = this.txtID.Text.Trim().Substring(0, Len);

            WSProcedureCtrl.ProcedureCtrl pctrl = new ProcedureCtrl();
            if (!pctrl.CheckModel(mid, SessionUser.ID, 0))
            {
                Methods.AjaxMessageBox(this, "序列号对应的品号与计划中的品号不一致!"); return;
            }

            if (Methods.getTypeOfModelID(mid) == "1")//如果是产品
            {
                if (this.TreeRShip.Nodes.Count > 0)
                {
                    foreach (TreeNode rnode in this.TreeRShip.Nodes[0].ChildNodes)
                    {
                        if (rnode.Value.Substring(0, Len) == mid)
                        {
                            Methods.AjaxMessageBox(this, "在关联树状列表中已存在!"); break;
                        }
                    }
                }

                try
                {
                    string name = "";
                    sqlaccess.Open();
                    ds = sqlaccess.OpenQuerry("select tm.Name,t.id  from ta_structure t,ta_model tm where t.id=tm.id and t.id='" + mid + "'");
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        name = ds.Tables[0].Rows[0][0].ToString();
                        this.generTree(mid, name);
                        this.generRSTree(this.txtID.Text.Trim(), name);
                    }
                }
                catch (Exception ex)
                {
                    LogManager.Write(this, ex.Message);
                }
                finally
                {
                    sqlaccess.Close();
                }
            }
            else
            {
                if (this.TreeStructure.Nodes.Count < 0)
                {
                    Methods.AjaxMessageBox(this, "请输入产品序列号"); return;
                }
                foreach (TreeNode node in this.TreeStructure.Nodes[0].ChildNodes)
                {
                    if (node.Value == mid)
                    {
                        if (this.TreeRShip.Nodes[0].ChildNodes.Count > 0)
                        {
                            foreach (TreeNode rnode in this.TreeRShip.Nodes[0].ChildNodes)
                            {
                                if (rnode.Value.Substring(0, Len) == mid)
                                {
                                    Methods.AjaxMessageBox(this, "在关联树状列表中已存在!"); break;
                                }
                                this.TreeRShip.Nodes[0].ChildNodes.Add(new TreeNode(this.txtID.Text.Trim(), this.txtID.Text.Trim()));
                                break;
                            }
                        }
                        else
                        {
                            this.TreeRShip.Nodes[0].ChildNodes.Add(new TreeNode(this.txtID.Text.Trim(), this.txtID.Text.Trim()));
                        }
                    }
                }
            }


            this.TreeRShip.ExpandAll();
            this.TreeStructure.ExpandAll();
        }
Exemplo n.º 3
0
        protected void btnAddRcd_Click(object sender, EventArgs e)
        {
            this.txtSN.Focus();
            if (this.btnAddRcd.Text == "验证产品序列号")
            {
                if (this.txtID.Text.Trim() == "")
                {
                    Methods.AjaxMessageBox(this, "产品序列号不能为空!"); return;
                }

                int rc = Methods.getModelIDCount(this.txtID.Text.Trim());
                if (rc == 0)
                {
                    Methods.AjaxMessageBox(this, "此产品序列号在数据库中不存在!"); return;
                }
                else if (rc < 0)
                {
                    Methods.AjaxMessageBox(this, "查询产品序列号时出现异常,详情请查看日志!"); return;
                }

                //ds = (DataSet)ViewState["tmpds"];
                //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                //{
                //    if (this.txtID.Text.Trim() == ds.Tables[0].Rows[i]["ID"].ToString())
                //    {
                //        Methods.AjaxMessageBox(this, "此产品序列号的记录已经存在!"); return;
                //    }
                //}

                int Len = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["MIDLenInSN"]);
                if (this.txtID.Text.Trim().Length <= Len)
                {
                    Methods.AjaxMessageBox(this, "此产品序列号长度必须" + Len + "位以上!"); return;
                }


                string PlanID = "";

                string ModelID = Methods.GetPlanPIDByEID(SessionUser.ID, out PlanID);

                string mid = this.txtID.Text.Trim().Substring(0, Len);
                //if(mid!=ModelID)
                //{
                //        Methods.AjaxMessageBox(this,"序列号对应的品号与计划中的品号不一致!"); return;
                //}
                WSProcedureCtrl.ProcedureCtrl pctrl = new ProcedureCtrl();
                if (!pctrl.CheckModel(mid, SessionUser.ID, 0))
                {
                    Methods.AjaxMessageBox(this, "序列号对应的品号与计划中的品号不一致!"); return;
                }
                ViewState["PlanID"] = PlanID;
                ViewState["mid"]    = mid;

                this.btnAddRcd.Text = "添加产品条码";
                this.lblCode.Text   = "扫描产品条码";
                this.txtID.Visible  = false;
                this.txtSN.Visible  = true;
                this.txtSN.Text     = "";
                this.txtSN.Focus();
            }
            else
            {
                ds = (DataSet)ViewState["tmpds"];

                DataRow r = ds.Tables[0].NewRow();//将数据源添加一新行
                r["ID"]      = this.txtID.Text.Trim();
                r["ModelID"] = ViewState["mid"];
                r["PlanID"]  = ViewState["PlanID"];
                r["SN"]      = this.txtSN.Text.Trim();

                ds.Tables[0].Rows.InsertAt(r, 0);
                ds.AcceptChanges();

                this.GridView1.DataSource = ds;
                this.GridView1.DataBind();

                this.btnAddRcd.Text = "验证产品序列号";
                this.lblCode.Text   = "扫描产品序列号";
                this.txtID.Visible  = true;
                this.txtID.Text     = "";
                this.txtSN.Visible  = false;

                this.txtID.Focus();
            }
        }