Пример #1
0
 protected void fvMaterialSupplierAdd_ItemCreated(object sender, EventArgs e)
 {
     //修改状态
     if (fvMaterialSupplierAdd.CurrentMode == FormViewMode.Edit)
     {
         //当前供应商名称文本框获取焦点
         var tb = (TextBox)fvMaterialSupplierAdd.FindControl("txtSupplierName");
         if (tb != null)
         {
             //设置焦点
             tb.Focus();
         }
     }
     //新增状态
     else if (fvMaterialSupplierAdd.CurrentMode == FormViewMode.Insert)
     {
         //当前供应商代码文本框
         var tb = (TextBox)fvMaterialSupplierAdd.FindControl("txtSupplierCode");
         if (tb != null)
         {
             //检查用户提供的供应商代码参数标识
             string supplierCode = Request["code"];
             if (supplierCode == null || supplierCode.Length <= 0)
             {
                 //获取最大供应商代码
                 using (var da = new t_material_supplierTableAdapter())
                 {
                     //获取已经使用的最大的代码
                     supplierCode = da.GetMaxCode().ToString();
                 }
             }
             if (supplierCode == null || supplierCode.Length <= 0)
             {
                 //设置默认供应商代码
                 tb.Text = "S0001";
             }
             else
             {
                 //设置默认供应商代码
                 tb.Text = string.Format(
                     "{0}{1:0000}",
                     supplierCode.Substring(0, 1),
                     (Math.Round(ydPublicMethod.Val(supplierCode.Substring(1)), 0) + 1)
                 );
             }
         }
         //当前供应商名称文本框获取焦点
         tb = (TextBox)fvMaterialSupplierAdd.FindControl("txtSupplierName");
         if (tb != null)
         {
             //设置焦点
             tb.Focus();
         }
     }
 }
Пример #2
0
 /// <summary>
 /// 更新或者新增供应商到供应商表
 /// </summary>
 /// <param name="daSupplier">操作供应商表的数据适配器</param>
 /// <param name="supplierCode">供应商代码</param>
 /// <param name="supplierName">供应商名称</param>
 /// <param name="addPerson">当前用户名称</param>
 private void UpdateToSupplierName(
     t_material_supplierTableAdapter daSupplier,
     out string supplierCode,
     string supplierName,
     string addPerson
 )
 {
     //检测供应商名称域供应商代码是否吻合
     var tab = daSupplier.GetDataLikeSupplierName(supplierName);
     //检测是否有查询到数据
     if (tab.Rows.Count > 0)
     {
         //首行数据
         var row = (DataSetMaterialSupplier.t_material_supplierRow)tab.Rows[0];
         //设置取得供应商代码
         supplierCode = row.supplier_code;
         //直接返回
         return;
     }
     //获取最大供应商代码
     using (var da = new t_material_supplierTableAdapter())
     {
         //获取已经使用的最大的代码
         supplierCode = da.GetMaxCode().ToString();
     }
     if (string.IsNullOrWhiteSpace(supplierCode))
     {
         //设置默认供应商代码
         supplierCode = "S0001";
     }
     else
     {
         //设置默认供应商代码
         supplierCode = string.Format(
             "{0}{1:0000}",
             supplierCode.Substring(0, 1),
             (Math.Round(ydPublicMethod.Val(supplierCode.Substring(1)), 0) + 1)
         );
     }
     //新增到供应商清单表
     if (daSupplier.InsertData(
         supplierCode,
         supplierName,
         addPerson
     ) <= 0)
     {
         throw new Exception("新增到供应商清单表失败!");
     }
 }