Example #1
0
 /// <summary>
 /// get all productionformware
 /// <summary>
 /// <param name=formid>formid</param>
 /// <param name=out emsg>return error message</param>
 ///<returns>details of all productionformware</returns>
 public BindingCollection <modProductionFormWare> GetProductionFormWare(string formid, out string emsg)
 {
     try
     {
         BindingCollection <modProductionFormWare> modellist = new BindingCollection <modProductionFormWare>();
         //Execute a query to read the categories
         string sql = string.Format("select form_id,seq,product_id,product_name,specify,size,qty,process_price,cost_price,warehouse_id,remark from production_form_ware where form_id='{0}' order by form_id,seq", formid);
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             while (rdr.Read())
             {
                 modProductionFormWare model = new modProductionFormWare();
                 model.FormId       = dalUtility.ConvertToString(rdr["form_id"]);
                 model.Seq          = dalUtility.ConvertToInt(rdr["seq"]);
                 model.ProductId    = dalUtility.ConvertToString(rdr["product_id"]);
                 model.ProductName  = dalUtility.ConvertToString(rdr["product_name"]);
                 model.Specify      = dalUtility.ConvertToString(rdr["specify"]);
                 model.Size         = dalUtility.ConvertToDecimal(rdr["size"]);
                 model.Qty          = dalUtility.ConvertToDecimal(rdr["qty"]);
                 model.ProcessPrice = dalUtility.ConvertToDecimal(rdr["process_price"]);
                 model.CostPrice    = dalUtility.ConvertToDecimal(rdr["cost_price"]);
                 model.WarehouseId  = dalUtility.ConvertToString(rdr["warehouse_id"]);
                 model.Remark       = dalUtility.ConvertToString(rdr["remark"]);
                 modellist.Add(model);
             }
         }
         emsg = null;
         return(modellist);
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Example #2
0
        private void toolExport_Click(object sender, EventArgs e)
        {
            if (DBGrid.CurrentRow == null)
            {
                return;
            }
            IList <modExcelRangeData> list = new List <modExcelRangeData>();
            modProductionForm         mod  = (modProductionForm)DBGrid.CurrentRow.DataBoundItem;

            list.Add(new modExcelRangeData(clsLxms.GetParameterValue("COMPANY_NAME"), "B1", "J1"));
            list.Add(new modExcelRangeData(clsLxms.GetParameterValue("COMPANY_ADDR"), "B2", "J2"));
            list.Add(new modExcelRangeData("电话:" + clsLxms.GetParameterValue("COMPANY_TEL") + "      传真:" + clsLxms.GetParameterValue("COMPANY_FAX"), "B3", "J3"));

            list.Add(new modExcelRangeData(mod.No, "J4", "J4"));
            list.Add(new modExcelRangeData(mod.DeptId, "D5", "H5"));
            list.Add(new modExcelRangeData(mod.FormDate.ToString("yyyy年MM月dd日"), "J5", "J5"));
            list.Add(new modExcelRangeData(string.Format("{0:C2}", mod.MaterialMny), "E15", "I15"));
            list.Add(new modExcelRangeData(string.Format("{0:C2}", mod.OtherMny), "E16", "I16"));
            list.Add(new modExcelRangeData(string.Format("{0:C2}", mod.KillMny), "E17", "I17"));
            list.Add(new modExcelRangeData(mod.OtherReason, "J16", "J16"));
            list.Add(new modExcelRangeData(mod.Remark, "D19", "J19"));
            list.Add(new modExcelRangeData(mod.AuditMan, "G21", "H21"));
            list.Add(new modExcelRangeData(mod.ShipMan, "J21", "J21"));
            BindingCollection <modProductionFormWare> listdetail = _dal.GetProductionFormWare(mod.FormId, out Util.emsg);

            for (int i = 0; i < listdetail.Count; i++)
            {
                modProductionFormWare modd = listdetail[i];
                string col = (7 + i).ToString().Trim();
                list.Add(new modExcelRangeData((i + 1).ToString(), "B" + col, "B" + col));
                list.Add(new modExcelRangeData(modd.ProductName, "C" + col, "D" + col));
                list.Add(new modExcelRangeData(modd.Specify, "E" + col, "F" + col));
                list.Add(new modExcelRangeData(modd.Qty.ToString(), "G" + col, "G" + col));
                list.Add(new modExcelRangeData(string.Format("{0:N2}", modd.ProcessPrice), "H" + col, "H" + col));
                list.Add(new modExcelRangeData(string.Format("{0:C2}", modd.Qty * modd.ProcessPrice), "I" + col, "I" + col));
                list.Add(new modExcelRangeData(modd.Remark, "J" + col, "J" + col));
            }
            clsExport.ExportByTemplate(list, "外发加工单", 1, 21, 10, 1);
        }