Пример #1
0
        protected void menuDelete_Click(object sender, EventArgs e)
        {
            FineUIPro.TreeNode treenode = firsttree.SelectedNode;

            string strID = treenode.NodeID.Trim();

            //需检查零件在组件和产品表中是否存在
            //未删除图片图纸
            if (strID != "")
            {
                pd_compongall_compose pcc = new pd_compongall_compose();
                pd_product_compose    ppc = new pd_product_compose();

                if (pcc.isExistdata("pd_compongall_compose", "composeID", strID, "ID").Trim() != "" &&
                    ppc.isExistdata("pd_product_compose", "ppid", strID, "ID").Trim() != "")
                {
                    Alert.Show("当前零件不能删除");
                    return;
                }

                List <Dictionary <string, string> > listdic = new List <Dictionary <string, string> >();
                List <string> listTablename     = new List <string>();
                Dictionary <string, string> dic = new Dictionary <string, string>();

                dic.Add("pd_machinekit", "cast(ID as varchar(36))='" + strID + "' ");
                listdic.Add(dic);
                listTablename.Add("pd_machinekit");

                dic = new Dictionary <string, string>();
                dic.Add("pd_machinekit_feature", "cast(pid as varchar(36))='" + strID + "' ");
                listdic.Add(dic);
                listTablename.Add("pd_machinekit_feature");

                dic = new Dictionary <string, string>();
                dic.Add("pd_3d", "cast(pid as varchar(36))='" + strID + "' ");
                listdic.Add(dic);
                listTablename.Add("pd_3d");

                dic = new Dictionary <string, string>();
                dic.Add("pd_blueprint", "cast(pid as varchar(36))='" + strID + "' ");
                listdic.Add(dic);
                listTablename.Add("pd_blueprint");

                dic = new Dictionary <string, string>();
                dic.Add("pd_photo", "cast(pid as varchar(36))='" + strID + "' ");
                listdic.Add(dic);
                listTablename.Add("pd_photo");

                dic = new Dictionary <string, string>();
                dic.Add("pd_cad", "cast(pid as varchar(36))='" + strID + "' ");
                listdic.Add(dic);
                listTablename.Add("pd_cad");

                int intresult = 0;

                pd_machinekit pm = new pd_machinekit();
                intresult = pm.deleteMutri(listdic, listTablename);

                inittree();

                Alert alert = new Alert();

                if (intresult > 0)
                {
                    alert.Icon    = Icon.Information;
                    alert.Message = "数据删除成功";
                }
                else
                {
                    alert.MessageBoxIcon = MessageBoxIcon.Error;
                    alert.Message        = "数据删除失败";
                }

                alert.Show();
            }
        }
Пример #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            FineUIPro.TreeNode treenode = firsttree.SelectedNode;

            if (treenode != null && treenode.Attributes["nodemenu"].ToString().Trim() == "2")
            {
                string strID      = treenode.NodeID.ToString().Trim();
                string strmtypeid = treenode.ParentNode.NodeID.Trim();

                Dictionary <string, string> dic = initDatadic();
                dic.Add("mtypeid", strmtypeid);

                pd_machinekit pm        = new pd_machinekit();
                int           intresult = 0;

                if (pm.isExistdata("pd_machinekit", "ID", strID, "ID").Trim() == "")
                {
                    if (pm.isExistdata("mname", dic["mname"].ToString().Trim(), strID, false).Trim() == "" &&
                        pm.isExistdata("mcode", dic["mcode"].ToString().Trim(), strID, false).Trim() == "")
                    {
                        dic.Add("ID", strID);
                        intresult = pm.add(dic, "pd_machinekit");
                    }
                    else
                    {
                        Alert.Show("零件名称或零件编码已经存在");
                        return;
                    }
                }
                else
                {
                    if (pm.isExistdata("mname", dic["mname"].ToString().Trim(), strID, true).Trim() == "" &&
                        pm.isExistdata("mcode", dic["mcode"].ToString().Trim(), strID, true).Trim() == "")
                    {
                        pd_compongall_compose pcc = new pd_compongall_compose();
                        pd_product_compose    ppc = new pd_product_compose();

                        if (pcc.isExistdata("pd_compongall_compose", "ID", strID, "ID").Trim() != "" &&
                            ppc.isExistdata("pd_product_compose", "ID", strID, "ID").Trim() != "")
                        {
                            Alert.Show("当前零件不能修改名称编码");
                            return;
                        }

                        intresult = pm.update(dic, "pd_machinekit", "cast(ID as varchar(36))", strID);
                    }
                    else
                    {
                        Alert.Show("零件名称或零件编码已经存在");
                        return;
                    }
                }

                inittree();

                Alert alert = new Alert();

                if (intresult == 1)
                {
                    alert.Icon    = Icon.Information;
                    alert.Message = "数据保存成功";
                }
                else
                {
                    alert.MessageBoxIcon = MessageBoxIcon.Error;
                    alert.Message        = "数据保存失败";
                }

                alert.Show();
            }
        }