Ejemplo n.º 1
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            if (!HelperUtility.hasPurviewOP("SalesContract_update"))
            {
                HelperUtility.showAlert("没有操作权限", "/BackManager/home.aspx");
            }
            int    intAdminId     = (int)ViewState["AdminId"];
            int    intId          = (int)ViewState["id"];
            int    intPage        = (int)ViewState["page"];
            string strThisPageUrl = "edit.aspx?id=" + intId + "&page=" + intPage;
            string strMsgError    = "";
            // 验证输入
            string strCompanyName = tbCompanyName.Text.Trim();

            if ("".Equals(strCompanyName))
            {
                strMsgError += "公司名不能为空!";
            }
            string strTimeSign = tbTimeSign.Value.ToString();

            if ("".Equals(strTimeSign))
            {
                strMsgError += "入库单签发时间不能为空!";
            }
            if (!HelperUtility.isDateType(strTimeSign))
            {
                strMsgError += "入库单签发时间格式不正确!";
            }
            string strComment = tbComment.Text.Trim();

            if (strComment.Length > 500)
            {
                strMsgError += "备注信息不能超过500个字数!";
            }
            if (!"".Equals(strMsgError))
            {
                HelperUtility.showAlert(strMsgError, strThisPageUrl);
                return;
            }
            string strPhotoUrls = "";
            // 验证完毕,提交数据
            ModelSalesContract model = BllSalesContract.getById(intId);

            if (strCompanyName.Contains("未知公司"))
            {
                model.id_company = 0;
            }
            else
            {
                model.id_company = BllSalesCompany.getIdByName(strCompanyName, intAdminId);
            }
            model.id_admin   = intAdminId;
            model.photo_urls = strPhotoUrls;
            model.comment    = strComment;
            model.time_sign  = Convert.ToDateTime(strTimeSign);
            // 更新数据库记录
            BllSalesContract.update(model);
            // 跳转回列表页
            Response.Redirect("/BackManager/sales_contract/list.aspx?page=" + intPage);
        }
Ejemplo n.º 2
0
        public static int update(ModelSalesContract model)
        {
            string strSQL = @"
UPDATE sales_contract
SET
  id_company = @id_company,
  id_admin = @id_admin,
  time_sign = @time_sign,
  time_create = @time_create,
  photo_urls = @photo_urls,
  comment = @comment,
  is_deleted = @is_deleted
WHERE
  id = @id
";

            MySqlParameter[] aryParams = new MySqlParameter[8];
            aryParams[0] = new MySqlParameter("@id_company", model.id_company);
            aryParams[1] = new MySqlParameter("@id_admin", model.id_admin);
            aryParams[2] = new MySqlParameter("@time_sign", model.time_sign);
            aryParams[3] = new MySqlParameter("@time_create", model.time_create);
            aryParams[4] = new MySqlParameter("@photo_urls", model.photo_urls);
            aryParams[5] = new MySqlParameter("@comment", model.comment);
            aryParams[6] = new MySqlParameter("@is_deleted", model.is_deleted);
            aryParams[7] = new MySqlParameter("@id", model.id);
            return(HelperMySql.ExecuteNonQuery(strSQL, aryParams));
        }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int intAdminId = HelperUtility.hasPurviewPage("SalesContract_update");
         ViewState["AdminId"] = intAdminId;
         // 本页只能从list.aspx的编辑页转过来
         // 因此要得到要修改的id值和页面的page值用于修改成功后返回
         int intId = HelperUtility.getQueryInt("id");
         ViewState["id"] = intId;
         int intPage = HelperUtility.getQueryInt("page");
         ViewState["page"] = intPage;
         // 绑定销售公司名称的下拉列表数据
         BllSalesCompany.bindRPT(rptName);
         // 根据入库单id查询得到入库单model
         ModelSalesContract model = BllSalesContract.getById(intId);
         int intCompanyId         = model.id_company;
         if (intCompanyId > 0)
         {
             tbCompanyName.Text = (BllSalesCompany.getById(intCompanyId)).name;
         }
         else
         {
             tbCompanyName.Text = "未知公司";
         }
         tbTimeSign.Value = model.time_sign.ToString("yyyy-MM-dd");
         tbComment.Text   = model.comment;
     }
 }
Ejemplo n.º 4
0
        // 导出入库单货品清单以便打印的Excel文件
        public static string[] setExcel(int intContractId)
        {
            // 得到此入库单的信息
            ModelSalesContract model = getById(intContractId);
            string             strCompanyName;

            if (model.id_company > 0)
            {
                strCompanyName = BllSalesCompany.getById(model.id_company).name;
            }
            else
            {
                strCompanyName = "预入库";
            }
            string strYear     = model.time_sign.Year.ToString();
            string strMonth    = model.time_sign.Month.ToString();
            string strDay      = model.time_sign.Day.ToString();
            string strDateShow = " " + strYear + "   " + strMonth + "   " + strDay;
            // 根据入库单ID得到此入库单下所有的入库货品记录,转成DataTable作为Excel文件的数据源
            DataTable objDTAll = BllSalesGoods.getAll(intContractId);
            DataSet   objDS    = HelperUtility.splitDataTable(objDTAll, 5);

            string[]  aryReturn = new string[objDS.Tables.Count];
            DataTable objDT;
            string    strExcelTemplateFileName = "/Excel/Template/01入库单.xlsx";
            string    strExcelOutFileName;

            for (int i = 0; i < objDS.Tables.Count; i++)
            {
                // 先对DataTable里的数据进行改造
                objDT           = objDS.Tables[i];
                objDT.TableName = "DataTable";
                WorkbookDesigner objDesigner = new WorkbookDesigner();
                objDesigner.SetDataSource("SalesCompany", "           " + strCompanyName);
                objDesigner.SetDataSource("DateShow", strDateShow);
                objDesigner.SetDataSource(objDT);
                // 设置要输出的每个Excel文件的文件名
                strExcelOutFileName = "/Excel/Export/入库单[" + strCompanyName +
                                      model.time_sign.ToString("yyMMdd") + "]-" + (i + 1) + ".xlsx";
                // 根据以上参数生成excel文件,并输出生成的excel文件路径
                HelperExcel.ExportExcelByTemplate(objDesigner, strExcelTemplateFileName, strExcelOutFileName);
                aryReturn[i] = strExcelOutFileName;
                // 处理完成后把表名改成别的名字,DS中不能有重名的Table
                objDT.TableName = "DataTable" + i;
            }
            return(aryReturn);
        }
Ejemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int intAdminId = HelperUtility.hasPurviewPage("SalesGoods_show");
         ViewState["AdminId"] = intAdminId;
         // 本页只能从list.aspx的编辑页转过来
         // 因此要得到要显示哪个入库单的cid值和页面的cpage值用于返回
         int intContractId = HelperUtility.getQueryInt("cid");
         if (intContractId == 0)
         {
             HelperUtility.showAlert("", "/BackManager/login.aspx");
         }
         ViewState["ContractId"]   = intContractId;
         ViewState["ContractPage"] = HelperUtility.getQueryInt("cpage");
         // 得到现在的页面值
         int intCurrentPage = HelperUtility.getQueryInt("page");
         if (intCurrentPage <= 0)
         {
             intCurrentPage = 1;
         }
         lblCurentPage.Text = intCurrentPage.ToString();
         LoadDataPage();
         // 设置其他控件值,以货币形式显示 2.5.ToString("C")
         // 得到入库单的信息
         ModelSalesContract model = BllSalesContract.getById(intContractId);
         if (model.id_company > 0)
         {
             lblCompanyName.Text = "【" + BllSalesCompany.getById(model.id_company).name + "】";
         }
         else
         {
             lblCompanyName.Text = "【预入库】";
         }
         lblTimeCreate.Text         = model.time_create.ToString("yyyy-MM-dd");
         lblPriceTotal.Text         = BllSalesGoods.getPriceTotal(intContractId).ToString("C");
         hlBackContract.NavigateUrl = "../sales_contract/list.aspx?page=" + ViewState["ContractPage"];
         hlAddNew.NavigateUrl       = "add.aspx?cid=" + intContractId;
         // 绑定所有入库单的下拉列表
         BllSalesContract.bindDDL(ddlSalesContract);
     }
 }
Ejemplo n.º 6
0
        public static int add(ModelSalesContract model)
        {
            string strSQL = @"
INSERT INTO sales_contract (
  id_company,
  id_admin,
  time_sign,
  time_create,
  photo_urls,
  comment,
  is_deleted
) VALUES (
  @id_company,
  @id_admin,
  @time_sign,
  @time_create,
  @photo_urls,
  @comment,
  @is_deleted
)";

            MySqlParameter[] aryParams = new MySqlParameter[7];
            aryParams[0] = new MySqlParameter("@id_company", model.id_company);
            aryParams[1] = new MySqlParameter("@id_admin", model.id_admin);
            aryParams[2] = new MySqlParameter("@time_sign", model.time_sign);
            aryParams[3] = new MySqlParameter("@time_create", model.time_create);
            aryParams[4] = new MySqlParameter("@photo_urls", model.photo_urls);
            aryParams[5] = new MySqlParameter("@comment", model.comment);
            aryParams[6] = new MySqlParameter("@is_deleted", model.is_deleted);
            if (HelperMySql.ExecuteNonQuery(strSQL, aryParams) > 0)
            {
                strSQL = "SELECT MAX(id) FROM sales_contract";
                object objReturn = HelperMySql.ExecuteScalar(strSQL);
                return(objReturn == null ? 0 : Convert.ToInt32(objReturn));
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 7
0
        public static ModelSalesContract getById(int intId)
        {
            string strSQL = @"SELECT * FROM sales_contract WHERE id = @id";

            MySqlParameter[] aryParams = new MySqlParameter[1];
            aryParams[0] = new MySqlParameter("@id", intId);
            DataTable objDT = HelperMySql.GetDataTable(strSQL, aryParams);

            if (objDT == null || objDT.Rows.Count <= 0)
            {
                return(null);
            }
            ModelSalesContract model = new ModelSalesContract();

            model.id          = Convert.ToInt32(objDT.Rows[0]["id"]);
            model.id_company  = Convert.ToInt32(objDT.Rows[0]["id_company"]);
            model.id_admin    = Convert.ToInt32(objDT.Rows[0]["id_admin"]);
            model.time_sign   = Convert.ToDateTime(objDT.Rows[0]["time_sign"]);
            model.time_create = Convert.ToDateTime(objDT.Rows[0]["time_create"]);
            model.photo_urls  = Convert.ToString(objDT.Rows[0]["photo_urls"]);
            model.comment     = Convert.ToString(objDT.Rows[0]["comment"]);
            model.is_deleted  = Convert.ToInt16(objDT.Rows[0]["is_deleted"]);
            return(model);
        }
Ejemplo n.º 8
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (!HelperUtility.hasPurviewOP("SalesContract_add"))
            {
                string strUrl = "/BackManager/home.aspx";
                HelperUtility.showAlert("没有操作权限", strUrl);
            }
            string strMsgError    = "";
            string strCompanyName = tbCompanyName.Text.Trim();

            if ("".Equals(strCompanyName))
            {
                strMsgError += "公司名不能为空!";
            }
            string strTimeSign = tbTimeSign.Value.ToString();

            if ("".Equals(strTimeSign))
            {
                strMsgError += "入库单签发时间不能为空!";
            }
            if (!HelperUtility.isDateType(strTimeSign))
            {
                strMsgError += "入库单签发时间格式不正确!";
            }
            string strComment = tbComment.Text.Trim();

            if (strComment.Length > 500)
            {
                strMsgError += "备注信息不能超过500个字数!";
            }
            if (!"".Equals(strMsgError))
            {
                HelperUtility.showAlert(strMsgError, "add.aspx");
                return;
            }
            string strPhotoUrls = "";
            // 验证完毕,提交数据
            int intAdminId           = (int)ViewState["AdminId"];
            ModelSalesContract model = new ModelSalesContract();

            if (strCompanyName.Contains("预入库"))
            {
                model.id_company = 0;
            }
            else
            {
                model.id_company = BllSalesCompany.getIdByName(strCompanyName, intAdminId);
            }
            model.id_admin   = intAdminId;
            model.time_sign  = Convert.ToDateTime(strTimeSign);
            model.photo_urls = strPhotoUrls;
            model.comment    = strComment;
            int intId = BllSalesContract.add(model);

            if (intId > 0)
            {
                string strUrl = "list.aspx";
                HelperUtility.showAlert("添加成功!", strUrl);
            }
            else
            {
                string strUrl = "add.aspx";
                HelperUtility.showAlert("添加失败,请联系管理员!", strUrl);
            }
        }
Ejemplo n.º 9
0
 public static int update(ModelSalesContract model)
 {
     return(DalSalesContract.update(model));
 }
Ejemplo n.º 10
0
 public static int add(ModelSalesContract model)
 {
     return(DalSalesContract.add(model));
 }