private void btnPrint() { try { try { gridView1.FocusedRowHandle -= 1; } catch { } DataTable dtTemp = ((DataView)gridControl1.DataSource).Table.Copy(); DataView dv = dtTemp.DefaultView; dv.Sort = "cInvCode,dDate"; dv.RowFilter = "NowQTY <> ''"; DataTable dt = dv.ToTable().Copy(); decimal dQTY = 0; ArrayList aList = new ArrayList(); RdInReport rep = new RdInReport(); int iRow = 0; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["NowQty"].ToString().Trim() == "") { continue; } decimal dNowQty = BaseFunction.ReturnDecimal(dt.Rows[i]["NowQty"]); if (dNowQty <= 0) { throw new Exception("ÐÐ" + (i + 1).ToString() + "ÊýÁ¿±ØÐë´óÓÚ0"); } iRow += 1; DataRow dr = rep.dataSet1.Tables[0].NewRow(); dr["Column1"] = dt.Rows[i]["cCode"].ToString().Trim(); dr["Column2"] = dt.Rows[i]["cInvCode"].ToString().Trim(); dr["Column3"] = dt.Rows[i]["cInvName"].ToString().Trim(); dr["Column4"] = dt.Rows[i]["cInvStd"].ToString().Trim(); dr["Column5"] = dt.Rows[i]["cInvm_unit"].ToString().Trim(); dr["Column6"] = dt.Rows[i]["cinva_unit"].ToString().Trim(); string s1 = ""; string s2 = ""; if (dt.Rows[i]["NowQty"].ToString().Trim() != "" && Convert.ToDecimal(dt.Rows[i]["NowQty"]) != 0) { dr["Column7"] = Convert.ToDecimal(dt.Rows[i]["NowQty"]); s1 = dr["Column7"].ToString().Trim(); dQTY = dQTY + Convert.ToDecimal(dt.Rows[i]["NowQty"]); } if (dt.Rows[i]["NowNum"].ToString().Trim() != "" && Convert.ToDecimal(dt.Rows[i]["NowNum"]) != 0) { dr["Column8"] = Convert.ToDecimal(dt.Rows[i]["NowNum"]); s2 = dr["Column8"].ToString().Trim(); } if (dt.Rows[i]["DType"].ToString().Trim().ToString().Trim() == "1") { dr["Column9"] = "Èë " + iRow; } if (dt.Rows[i]["DType"].ToString().Trim().ToString().Trim() == "3") { dr["Column9"] = "µ½ " + iRow; } string sBarCode = dt.Rows[i]["DType"].ToString().Trim().ToString().Trim() + "$" + FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName.Substring(7, 3).Trim() + "$" + dt.Rows[i]["modetailsid"].ToString().Trim() + "$" + s1 + "$" + s2; dr["Column10"] = sBarCode; if (dt.Rows[i]["cdefine36"].ToString().Trim() != "") { dr["Column11"] = Convert.ToDateTime(dt.Rows[i]["cdefine36"]).ToString("yyyy-MM-dd"); } else if (dt.Rows[i]["cdefine37"].ToString().Trim() != "") { dr["Column11"] = Convert.ToDateTime(dt.Rows[i]["cdefine37"]).ToString("yyyy-MM-dd"); } else { dr["Column11"] = Convert.ToDateTime(dt.Rows[i]["dDate"]).ToString("yyyy-MM-dd"); } dr["Column12"] = dt.Rows[i]["iquantity"].ToString().Trim(); if (dt.Rows[i]["iNum"].ToString().Trim() != "" && Convert.ToDecimal(dt.Rows[i]["iNum"]) != 0) { dr["Column13"] = dt.Rows[i]["iNum"].ToString().Trim(); } dr["Column14"] = dt.Rows[i]["inqty"].ToString().Trim(); if (dt.Rows[i]["innum"].ToString().Trim() != "" && Convert.ToDecimal(dt.Rows[i]["innum"]) != 0) { dr["Column15"] = dt.Rows[i]["innum"].ToString().Trim(); } dr["Column16"] = dt.Rows[i]["citemcode"].ToString().Trim(); rep.dataSet1.Tables[0].Rows.Add(dr); } } #region µÇ¼Ç´òÓ¡ long iÕ»°å1 = ReturnObjectToLong(txtÕ»°å1.Text.Trim()); long iÕ»°å2 = ReturnObjectToLong(txtÕ»°å2.Text.Trim()); long iÕ»°å3 = ReturnObjectToLong(txtÕ»°å3.Text.Trim()); long iÕ»°å4 = ReturnObjectToLong(txtÕ»°å4.Text.Trim()); long iÕ»°å5 = ReturnObjectToLong(txtÕ»°å5.Text.Trim()); long iÕ»°å6 = ReturnObjectToLong(txtÕ»°å6.Text.Trim()); long iÕ»°å7 = ReturnObjectToLong(txtÕ»°å7.Text.Trim()); long iÕ»°å8 = ReturnObjectToLong(txtÕ»°å8.Text.Trim()); long iÕ»°å9 = ReturnObjectToLong(txtÕ»°å9.Text.Trim()); long iÕ»°å10 = ReturnObjectToLong(txtÕ»°å10.Text.Trim()); string sGuid = Guid.NewGuid().ToString(); string sSQL = "insert into UFDLImport..Õ»°å´òÓ¡µÇ¼Ç(GUID, µ¥¾ÝÀàÐÍ, Õ»°å1, Õ»°å2, Õ»°å3, Õ»°å4, Õ»°å5, Õ»°å6, Õ»°å7, Õ»°å8, Õ»°å9, Õ»°å10,ÊýÁ¿)" + "values('" + sGuid + "','ίÍâµ½»õ'," + iÕ»°å1 + "," + iÕ»°å2 + "," + iÕ»°å3 + "," + iÕ»°å4 + "," + iÕ»°å5 + "," + iÕ»°å6 + "," + iÕ»°å7 + "," + iÕ»°å8 + "," + iÕ»°å9 + "," + iÕ»°å10 + "," + rep.dataSet1.Tables[0].Rows.Count + ")"; clsSQLCommond.ExecSql(sSQL); sSQL = "select * from UFDLImport..Õ»°å´òÓ¡µÇ¼Ç where GUID = '" + sGuid + "'"; DataTable dtÕ»°å´òÓ¡µÇ¼Ç = clsSQLCommond.ExecQuery(sSQL); string sIDÕ»°å´òÓ¡µÇ¼Ç = ""; if (dtÕ»°å´òÓ¡µÇ¼Ç != null && dtÕ»°å´òÓ¡µÇ¼Ç.Rows.Count > 0) { sIDÕ»°å´òÓ¡µÇ¼Ç = dtÕ»°å´òÓ¡µÇ¼Ç.Rows[0]["iID"].ToString().Trim(); } #endregion DataTable dt2 = rep.dataSet1.Tables[1]; DataRow dRowTe = dt2.NewRow(); dRowTe["Column1"] = rep.dataSet1.Tables[0].Rows.Count; dRowTe["Column2"] = "¹©Ó¦ÉÌ£º" + txtVenCode.Text.Trim() + "--" + txtVenName.Text.Trim(); dRowTe["Column3"] = "ÖƵ¥ÈÕÆÚ£º" + DateTime.Parse(FrameBaseFunction.ClsBaseDataInfo.sLogDate).ToString("yyyy-MM-dd"); dRowTe["Column4"] = "ÖƵ¥ÈË:" + FrameBaseFunction.ClsBaseDataInfo.sUserName; dRowTe["Column5"] = "ÊýÁ¿ºÏ¼Æ£º" + dQTY.ToString().Trim(); string sÕ»°å = ""; if (ReturnObjectToLong(txtÕ»°å1.Text.Trim()) > 0) { sÕ»°å = sÕ»°å + labelÕ»°å1.Text + "[ " + txtÕ»°å1.Text.Trim() + " ] "; } if (ReturnObjectToLong(txtÕ»°å2.Text.Trim()) > 0) { sÕ»°å = sÕ»°å + labelÕ»°å2.Text + "[ " + txtÕ»°å2.Text.Trim() + " ] "; } if (ReturnObjectToLong(txtÕ»°å3.Text.Trim()) > 0) { sÕ»°å = sÕ»°å + labelÕ»°å3.Text + "[ " + txtÕ»°å3.Text.Trim() + " ] "; } if (ReturnObjectToLong(txtÕ»°å4.Text.Trim()) > 0) { sÕ»°å = sÕ»°å + labelÕ»°å4.Text + "[ " + txtÕ»°å4.Text.Trim() + " ] "; } if (ReturnObjectToLong(txtÕ»°å5.Text.Trim()) > 0) { sÕ»°å = sÕ»°å + labelÕ»°å5.Text + "[ " + txtÕ»°å5.Text.Trim() + " ] "; } if (ReturnObjectToLong(txtÕ»°å6.Text.Trim()) > 0) { sÕ»°å = sÕ»°å + labelÕ»°å6.Text + "[ " + txtÕ»°å6.Text.Trim() + " ] "; } if (ReturnObjectToLong(txtÕ»°å7.Text.Trim()) > 0) { sÕ»°å = sÕ»°å + labelÕ»°å7.Text + "[ " + txtÕ»°å7.Text.Trim() + " ] "; } if (ReturnObjectToLong(txtÕ»°å8.Text.Trim()) > 0) { sÕ»°å = sÕ»°å + labelÕ»°å8.Text + "[ " + txtÕ»°å8.Text.Trim() + " ] "; } if (ReturnObjectToLong(txtÕ»°å9.Text.Trim()) > 0) { sÕ»°å = sÕ»°å + labelÕ»°å9.Text + "[ " + txtÕ»°å9.Text.Trim() + " ] "; } if (ReturnObjectToLong(txtÕ»°å10.Text.Trim()) > 0) { sÕ»°å = sÕ»°å + labelÕ»°å10.Text + "[ " + txtÕ»°å10.Text.Trim() + " ] "; } dRowTe["Column11"] = sÕ»°å; dRowTe["Column12"] = sIDÕ»°å´òÓ¡µÇ¼Ç; dt2.Rows.Add(dRowTe); rep.ShowPreview(); } catch (Exception ee) { MessageBox.Show("¼ÓÔØ´òӡʧ°Ü! \n\nÔÒò:\n " + ee.Message, "Ìáʾ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAudit() { try { RdInReport rep = new RdInReport(); try { gridView1.FocusedRowHandle -= 1; } catch { } for (int i = 0; i < gridView1.RowCount; i++) { if (gridView1.GetRowCellValue(i, gridColumn16).ToString().Trim() == "" || Convert.ToDecimal(gridView1.GetRowCellValue(i, gridColumn16)) == 0) { continue; } decimal dQty = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridColumn16)); if (dQty <= 0) { throw new Exception("行" + (i + 1).ToString() + "送货数量必须大于0"); } DateTime d1 = DateTime.Now; if (gridView1.GetRowCellValue(i, gridColumn23).ToString().Trim() != "") { d1 = Convert.ToDateTime(gridView1.GetRowCellValue(i, gridColumn23)); } else if (gridView1.GetRowCellValue(i, gridColumn21).ToString().Trim() != "") { d1 = Convert.ToDateTime(gridView1.GetRowCellValue(i, gridColumn21)); } DateTime d2 = DateTime.Today.AddDays(7); if (d1 > d2) { throw new Exception("行" + (i + 1).ToString() + "提前7天,不能送货"); } } DataTable dtTemp = ((DataView)gridControl1.DataSource).Table.Copy(); DataView dv = dtTemp.DefaultView; dv.Sort = "cInvCode,dArriveDate"; dv.RowFilter = "NowQTY <> ''"; DataTable dt = dv.ToTable().Copy(); int iRow = 0; decimal dQTY = 0; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["NowQty"].ToString().Trim() != "") { iRow += 1; DataRow dr = rep.dataSet1.Tables[0].NewRow(); dr["Column1"] = dt.Rows[i]["cpoid"].ToString().Trim(); dr["Column2"] = dt.Rows[i]["cInvCode"].ToString().Trim(); dr["Column3"] = dt.Rows[i]["cInvName"].ToString().Trim(); dr["Column4"] = dt.Rows[i]["cInvStd"].ToString().Trim(); dr["Column5"] = dt.Rows[i]["cinvm_unit"].ToString().Trim(); dr["Column6"] = dt.Rows[i]["cInva_unit"].ToString().Trim(); string s1 = ""; string s2 = ""; if (dt.Rows[i]["NowQty"].ToString().Trim() != "" && Convert.ToDecimal(dt.Rows[i]["NowQty"]) != 0) { dr["Column7"] = Convert.ToDecimal(dt.Rows[i]["NowQty"]); s1 = dr["Column7"].ToString().Trim(); dQTY = dQTY + Convert.ToDecimal(dt.Rows[i]["NowQty"]); } if (dt.Rows[i]["NowNum"].ToString().Trim() != "" && Convert.ToDecimal(dt.Rows[i]["NowNum"]) != 0) { dr["Column8"] = Convert.ToDecimal(dt.Rows[i]["NowNum"]); s2 = dr["Column8"].ToString().Trim(); } if (dt.Rows[i]["DType"].ToString().Trim().ToString().Trim() == "0") { dr["Column9"] = "入 " + iRow; } if (dt.Rows[i]["DType"].ToString().Trim().ToString().Trim() == "2") { dr["Column9"] = "到 " + iRow; } string sBarCode = dt.Rows[i]["DType"].ToString().Trim().ToString().Trim() + "$200$" + dt.Rows[i]["id"].ToString().Trim() + "$" + s1 + "$" + s2; dr["Column10"] = sBarCode; if (dt.Rows[i]["cdefine36"].ToString().Trim() != "") { dr["Column11"] = Convert.ToDateTime(dt.Rows[i]["cdefine36"]).ToString("yyyy-MM-dd"); } else if (dt.Rows[i]["cdefine37"].ToString().Trim() != "") { dr["Column11"] = Convert.ToDateTime(dt.Rows[i]["cdefine37"]).ToString("yyyy-MM-dd"); } else { dr["Column11"] = Convert.ToDateTime(dt.Rows[i]["dArriveDate"]).ToString("yyyy-MM-dd"); } dr["Column12"] = dt.Rows[i]["iquantity"].ToString().Trim(); if (dt.Rows[i]["iNum"].ToString().Trim() != "" && Convert.ToDecimal(dt.Rows[i]["iNum"]) != 0) { dr["Column13"] = dt.Rows[i]["iNum"].ToString().Trim(); } dr["Column14"] = dt.Rows[i]["inqty"].ToString().Trim(); if (dt.Rows[i]["innum"].ToString().Trim() != "" && Convert.ToDecimal(dt.Rows[i]["innum"]) != 0) { dr["Column15"] = dt.Rows[i]["innum"].ToString().Trim(); } dr["Column16"] = dt.Rows[i]["citemcode"].ToString().Trim(); dr["Column17"] = dt.Rows[i]["citemcode"].ToString().Trim(); dr["Column18"] = dt.Rows[i]["母件编码"].ToString().Trim(); dr["Column19"] = dt.Rows[i]["母件名称"].ToString().Trim(); rep.dataSet1.Tables[0].Rows.Add(dr); } } DataTable dt2 = rep.dataSet1.Tables[1]; DataRow dRowTe = dt2.NewRow(); dRowTe["Column1"] = rep.dataSet1.Tables[0].Rows.Count; dRowTe["Column2"] = "供应商:" + txtVenCode.Text.Trim() + "--" + txtVenName.Text.Trim(); dRowTe["Column3"] = "制单日期:" + DateTime.Parse(FrameBaseFunction.ClsBaseDataInfo.sLogDate).ToString("yyyy-MM-dd"); dRowTe["Column4"] = "制单人:" + FrameBaseFunction.ClsBaseDataInfo.sUserName; dRowTe["Column5"] = "数量合计:" + dQTY.ToString().Trim(); if (chk库存.Checked) { dRowTe["Column6"] = "使用厂商库存"; } else { dRowTe["Column6"] = ""; } dt2.Rows.Add(dRowTe); rep.ShowPreview(); } } catch (Exception ee) { MessageBox.Show("加载打印失败! \n\n原因:\n " + ee.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }