示例#1
0
        private void initinfo(string strID)
        {
            pd_outbuykit ok = new pd_outbuykit();
            DataTable    dt = ok.getEditdata(strID);

            DataRow r = dt.Rows[0];

            editID.Text        = strID;
            oname.Text         = r["oname"].ToString().Trim();
            ocode.Text         = r["ocode"].ToString().Trim();
            specification.Text = r["specification"].ToString().Trim();
            otype.Text         = r["otype"].ToString();
            imgPhoto.ImageUrl  = ok.getPhotoFileName(strID) == "" ? DEFAULT_IMAGEPATH : IMAGEPATH + ok.getPhotoFileName(strID);
        }
示例#2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int[] intRowindexarray = Grid1.SelectedRowIndexArray;

            if (intRowindexarray.Length > 0)
            {
                pd_outbuykit ok    = new pd_outbuykit();
                object[]     keys  = Grid1.DataKeys[intRowindexarray[0]];
                string       strID = keys[0].ToString();

                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("isdelid", "2");
                string photoID = ok.getPhotoID(strID);
                if (photoID != "")
                {
                    // 返回与指定虚拟路径相对应的物理路径即绝对路径
                    string filePath = Server.MapPath(IMAGEPATH + ok.getPhotoFileName(strID));
                    // 删除该文件
                    System.IO.File.Delete(filePath);
                    int intresultPhoto = new pd_photo().delete("pd_photo", "ID", ok.getPhotoID(strID));
                }
                int intresult = ok.delete("pd_outbuykit", "ID", strID);

                setPageContent(1);

                Alert alert = new Alert();

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


                alert.Show();
            }
            else
            {
                Alert.Show("请选择记录!");
            }
        }
示例#3
0
        private void BindGrid()
        {
            string stroname = Foname.Text.Trim();

            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("oname", stroname);

            int    intPageindex     = Convert.ToInt32(CurPage.Text.Trim());
            int    intPagesize      = Convert.ToInt32(GridPageSize.Text.Trim());
            string strSort          = Grid1.SortField;
            string strSortDirection = Grid1.SortDirection;

            pd_outbuykit ok  = new pd_outbuykit();
            DataTable    dt  = ok.getBindDataAsdt(dic, strSort, strSortDirection, intPagesize, intPageindex);
            DataTable    dt1 = ok.getBindDataAsdt(dic, strSort, strSortDirection);

            TotalPage.Text = dt1.Rows.Count.ToString();

            Grid1.DataSource = dt;
            Grid1.DataBind();
        }
示例#4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Dictionary <string, string> dicOutBuykit = initDatadicOutBuykit();
            Dictionary <string, string> dicPhoto     = initDatadicPhoto();
            string       strID           = editID.Text.ToString().Trim();
            pd_outbuykit ok              = new pd_outbuykit();
            pd_photo     ph              = new pd_photo();
            int          intresultRecord = 0;
            int          intresultPhoto  = 0;

            if (strID == "")
            {
                string standardKitID = Guid.NewGuid().ToString();
                dicOutBuykit.Add("ID", standardKitID);
                dicOutBuykit.Add("isdelid", "1");
                dicPhoto.Add("ID", Guid.NewGuid().ToString());
                dicPhoto.Add("isdelid", "1");
                dicPhoto.Add("pid", standardKitID);
                string str_ocode = dicOutBuykit["ocode"].ToString().Trim();
                string str_oname = dicOutBuykit["oname"].ToString().Trim();
                if ((ok.isExistdata("pd_outbuykit", "ocode", str_ocode, "ocode").Trim() != "") || (ok.isExistdata("pd_outbuykit", "oname", str_oname, "oname").Trim() != ""))
                {
                    Alert.Show(" 该外购件名称或代码已经存在!");
                }
                else
                {
                    intresultRecord = ok.add(dicOutBuykit, "pd_outbuykit");
                    intresultPhoto  = 1;
                    if ((filePhoto.HasFile) && (intresultRecord == 1))
                    {
                        intresultPhoto = ph.add(dicPhoto, "pd_photo");
                    }
                }
            }
            else
            {
                intresultRecord = ok.update(dicOutBuykit, "pd_outbuykit", "ID", strID);
                //exist photo->update || else ->add
                string photoID = ok.getPhotoID(strID).Trim();
                if (intresultRecord == 1)
                {
                    if (photoID != "")

                    {
                        // 返回与指定虚拟路径相对应的物理路径即绝对路径
                        string filePath = Server.MapPath(IMAGEPATH + ok.getPhotoFileName(strID));
                        // 删除该文件
                        System.IO.File.Delete(filePath);
                        intresultPhoto = ph.update(dicPhoto, "pd_photo", "ID", photoID);
                    }
                    else
                    {
                        dicPhoto.Add("ID", Guid.NewGuid().ToString());
                        dicPhoto.Add("isdelid", "1");
                        dicPhoto.Add("pid", strID);
                        intresultPhoto = ph.add(dicPhoto, "pd_photo");
                    }
                }
            }

            if (CurPage.Text.Trim() == "")
            {
                setPageContent(1);
            }
            else
            {
                setPageContent(5);
            }

            Alert alert = new Alert();

            if ((intresultRecord == 1) && (intresultPhoto == 1))
            {
                alert.Icon    = Icon.Information;
                alert.Message = "数据保存成功";
                imgPhoto.Reset();
                filePhoto.Reset();
            }
            else if (intresultRecord == 0)
            {
                alert.MessageBoxIcon = MessageBoxIcon.Error;
                alert.Message        = "数据保存失败";
                filePhoto.Reset();
                imgPhoto.Reset();
            }
            else if (intresultPhoto == 0)
            {
                alert.MessageBoxIcon = MessageBoxIcon.Error;
                alert.Message        = "图片保存失败";
                filePhoto.Reset();
                imgPhoto.Reset();
            }


            alert.Show();
        }