using System; using System.Collections.Generic; using System.Text; using System.Data; using Pub_Class; using Model; using System.Windows.Forms; using System.Drawing; using System.IO; namespace BLL { public class ClsPub_BLL { // /// /// ÉèÖúϼÆÍø¸ñÊôÐÔ(Ö»µ÷ÁÐ¿í²»µ÷Êý¾Ý) /// public static void SetGridsum_NoData(DataGridView grdSum, DataGridView grdMain) { Int32 i; grdSum.Enabled = false; grdSum.Width = grdMain.Width; grdSum.RowHeadersVisible = false; grdSum.ColumnHeadersVisible = false; //if (grdSum.Rows.Count == 0) //{ grdSum.RowCount = 1; grdSum.ColumnCount = grdMain.ColumnCount; //} grdSum.HorizontalScrollingOffset = grdMain.HorizontalScrollingOffset; grdSum.Rows[0].Height = 20; grdSum.Height = 20; //for (i = 1; i < oGridsum.ColumnCount; i++) //{ // grdSum.Rows[0].Cells[i].Value = ""; //} grdSum.Rows[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; grdSum.Rows[0].DefaultCellStyle.BackColor = Color.Khaki; for (i = 0; i < grdMain.ColumnCount; i++) { grdSum.Columns[i].Visible = grdMain.Columns[i].Visible; grdSum.Columns[i].Width = grdMain.Columns[i].Width; if (grdMain.Rows.Count == 0) { grdSum.Rows[0].Cells[i].Value = ""; } } grdSum.Rows[0].Cells[0].Value = "ºÏ¼Æ"; grdSum.Width = grdMain.Width; //RefreshNoCol(); } //Éϲéϲé public static void UpBillShow(DataGridView ogrd, bool isUp, Form oMainFrm) { //string tSql; //string FrmCaption = ""; //string FrmName = ""; //string sViewName = ""; //string tRight = ""; //string BillType = ""; //DataSet Ds; //if (ogrd.CurrentRow == null) //{ // return; //} //if (isUp == false) //{ // tSql = ClsPub.GetDownBillSql(ref BillType, ref tRight, ref FrmName, ref FrmCaption, ref sViewName, ogrd.Rows[ogrd.CurrentRow.Index].Cells[ClsPub.Fun_GetCol(ogrd, "µ¥¾ÝÀàÐÍ")].Value.ToString(), ClsPub.isLong(ogrd.Rows[ogrd.CurrentRow.Index].Cells[ClsPub.Fun_GetCol(ogrd, "hmainid")].Value), ClsPub.isLong(ogrd.Rows[ogrd.CurrentRow.Index].Cells[ClsPub.Fun_GetCol(ogrd, "hsubid")].Value)); //} //else //{ // tSql = ClsPub.GetUpBillSql(ref BillType, ref tRight, ref FrmName, ref FrmCaption, ref sViewName, ogrd.Rows[ogrd.CurrentRow.Index].Cells[ClsPub.Fun_GetCol(ogrd, "Ô´µ¥ÀàÐÍ")].Value.ToString(), ClsPub.isLong(ogrd.Rows[ogrd.CurrentRow.Index].Cells[ClsPub.Fun_GetCol(ogrd, "Ô´µ¥Ö÷ÄÚÂë")].Value), ClsPub.isLong(ogrd.Rows[ogrd.CurrentRow.Index].Cells[ClsPub.Fun_GetCol(ogrd, "Ô´µ¥×ÓÄÚÂë")].Value)); //} //if (tSql.Trim() == "") //{ // MessageBox.Show("ûÓйØÁªµ¥¾Ý£¡"); // return; //} //if (tRight.Trim() != "") //{ // if (!ClsPub.Security_Log(tRight.Trim(), 1, true, DBUtility.ClsPub.CurUserName)) // { // return; // } //} //if (tSql.Trim() != "") //{ // Xt_UpDownBillList oFrm = new Xt_UpDownBillList(); // if (ClsPub.isBool(oFrm.WindowState) == true) // { // oFrm.MdiParent = oMainFrm; // oFrm.ModCaption = FrmCaption; // oFrm.FrmName = FrmName; // oFrm.ViewName = sViewName; // oFrm.sSQL_Out = tSql.Trim(); // oFrm.BillType = BillType; // oFrm.timer1.Enabled = true; // oFrm.Show(); // } //} //else //{ // MessageBox.Show("ûÓйØÁªµ¥¾Ý£¡"); //} } //ÏÔʾ¶ÔÓ¦µ¥¾Ý public static void Sub_ShowRelationBill(string sType) { switch (sType) { case "1101": break; case "1102": break; case "24": break; } } public static void SetXY(Form frm, Panel p, TextBox t, ref int x, ref int y) { x = frm.Location.X + p.Location.X + t.Location.X; y = frm.Location.Y + p.Location.Y + t.Location.Y + t.Height + 35; } public static void SetXY(Form frm, Panel p, GroupBox g, TextBox t, ref int x, ref int y) { x = frm.Location.X + p.Location.X + g.Location.X + t.Location.X; y = frm.Location.Y + p.Location.Y + g.Location.Y + t.Location.Y + t.Height + 35; } ////ÉèÖÃÍø¸ñ²Ö¿â IF //public static void SetGridWarehouse_IF(Int64 HWhID, DataGridView grdMain, int HMaterIDCol, int HWHIDCol, int HWHNameCol, int HWHNumberCol) //{ // if (HWhID == 0) // { // return; // } // DAL.ClsIF_Warehouse_View oWH = new DAL.ClsIF_Warehouse_View(); // if (oWH.GetInfoByID(HWhID)) // { // for (int i = 0; i < grdMain.Rows.Count; i++) // { // if (ClsPub.isLong(grdMain.Rows[i].Cells[HMaterIDCol].Value) != 0) // { // grdMain.Rows[i].Cells[HWHIDCol].Value = oWH.omodel.HItemID; // grdMain.Rows[i].Cells[HWHNameCol].Value = oWH.omodel.HName; // grdMain.Rows[i].Cells[HWHNumberCol].Value = oWH.omodel.HNumber; // } // } // } //} //ÉèÖÃÍø¸ñ²Ö¿â public static void SetGridWarehouse_K3(Int64 HWhID,DataGridView grdMain, int HMaterIDCol,int HWHIDCol,int HWHNameCol,int HWHNumberCol) { //if (HWhID == 0) //{ // return; //} //DAL.ClsIF_Warehouse_View oWH = new DAL.ClsIF_Warehouse_View(); //if (oWH.GetInfoByID(HWhID)) //{ // for (int i = 0; i < grdMain.Rows.Count; i++) // { // if (ClsPub.isLong(grdMain.Rows[i].Cells[HMaterIDCol].Value) != 0) // { // grdMain.Rows[i].Cells[HWHIDCol].Value = oWH.omodel.HItemID; // grdMain.Rows[i].Cells[HWHNameCol].Value = oWH.omodel.HName; // grdMain.Rows[i].Cells[HWHNumberCol].Value = oWH.omodel.HNumber; // } // } //} } //Çå¿ÕÎı¾ /// /// Çå¿ÕÎı¾ ,Îı¾±»É¾³ýʱ£¬TAGÇå¿Õ /// public static void Sub_ClearText(TextBox txt) { if (txt.Text.Trim() == "") { txt.Tag = "0"; } } //¸ù¾Ý±íÍ·²¹¿ÛÏîÄ¿£¬ÉèÖÃÍø¸ñ²¹¿ÛÏîÄ¿ /// /// ¸ù¾Ý±íÍ·²¹¿ÛÏîÄ¿£¬ÉèÖÃÍø¸ñ²¹¿ÛÏîÄ¿ /// public static void SetGridDuSubsidyItem(Int64 HDuSubsidyItemID, DataGridView grdMain, int HEmpIDCol, int i, int HDuSubsidyItemIDCol, int HDuSubsidyItemNumberCol, int HDuSubsidyItemNameCol) { if (HDuSubsidyItemID == 0) { return; } DAL.ClsGy_DuSubsidyItem_View oDu = new DAL.ClsGy_DuSubsidyItem_View(); if (oDu.GetInfoByID(HDuSubsidyItemID)) { grdMain.Rows[i].Cells[HDuSubsidyItemIDCol].Value = oDu.omodel.HItemID; grdMain.Rows[i].Cells[HDuSubsidyItemNumberCol].Value = oDu.omodel.HNumber; grdMain.Rows[i].Cells[HDuSubsidyItemNameCol].Value = oDu.omodel.HName; } } //ÉèÖÃÍø¸ñ²¹¿ÛÏîÄ¿ /// /// ÉèÖÃÍø¸ñ²¹¿ÛÏîÄ¿ /// /// public static void SetGridDuSubsidyItem(Int64 HDuSubsidyItemID, DataGridView grdMain, int HEmpIDCol, int HDuSubsidyItemIDCol, int HDuSubsidyItemNumberCol, int HDuSubsidyItemNameCol) { if (HDuSubsidyItemID == 0) { return; } DAL.ClsGy_DuSubsidyItem_View oDu = new DAL.ClsGy_DuSubsidyItem_View(); if (oDu.GetInfoByID(HDuSubsidyItemID)) { for (int i = 0; i < grdMain.Rows.Count; i++) { if (ClsPub.isLong(grdMain.Rows[i].Cells[HEmpIDCol].Value) != 0) { grdMain.Rows[i].Cells[HDuSubsidyItemIDCol].Value = oDu.omodel.HItemID; grdMain.Rows[i].Cells[HDuSubsidyItemNumberCol].Value = oDu.omodel.HNumber; grdMain.Rows[i].Cells[HDuSubsidyItemNameCol].Value = oDu.omodel.HName; } } } } //ÉèÖÃÍø¸ñÈÕÆÚ /// /// ÉèÖÃÍø¸ñÈÕÆÚ /// /// public static void SetGridDateTime(DateTime HBeginTime, DateTime HEndTime, DataGridView grdMain, int HEmpIDCol, int HBeginTimeCol, int HEndTimeCol) { for (int i = 0; i < grdMain.Rows.Count; i++) { if (ClsPub.isLong(grdMain.Rows[i].Cells[HEmpIDCol].Value) != 0) { grdMain.Rows[i].Cells[HBeginTimeCol].Value = HBeginTime.ToShortTimeString(); grdMain.Rows[i].Cells[HEndTimeCol].Value = HEndTime.ToShortTimeString(); } } } //¸ù¾Ý±íÍ·ÈÕÆÚ£¬ÉèÖÃÍø¸ñÈÕÆÚ /// /// ¸ù¾Ý±íÍ·ÈÕÆÚ£¬ÉèÖÃÍø¸ñÈÕÆÚ /// public static void SetGridDateTime(DateTime HBeginTime, DateTime HEndTime, DataGridView grdMain, int HEmpIDCol, int i, int HBeginTimeCol, int HEndTimeCol) { grdMain.Rows[i].Cells[HBeginTimeCol].Value = HBeginTime.ToShortTimeString(); grdMain.Rows[i].Cells[HEndTimeCol].Value = HEndTime.ToShortTimeString(); } //Ñ¡ÔñÈÕÆÚ¿ò /// /// Ñ¡ÔñÈÕÆÚ¿ò /// /// public static void Sub_SelectDate(DataGridView grd,int iRow,int HDateCol) { FrmSelectDate oDate = new FrmSelectDate(); oDate.ShowDialog(); if (oDate.isSelected == true) { grd.Rows[iRow].Cells[HDateCol].Value = oDate.MC1.SelectionStart.ToShortDateString(); grd.Rows[iRow].Cells[HDateCol].Value = oDate.MC1.SelectionEnd.ToShortDateString(); } } //Ñ¡ÔñÈÕÆÚ¿ò /// /// Ñ¡ÔñÈÕÆÚ¿ò /// /// public static void Sub_SelectDate(DataGridView grd, int iRow, int HDateCol,DataGridViewTextBoxEditingControl oEdit) { FrmSelectDate oDate = new FrmSelectDate(); oDate.ShowDialog(); if (oDate.isSelected == true) { grd.Rows[iRow].Cells[HDateCol].Value = oDate.MC1.SelectionStart.ToShortDateString(); grd.Rows[iRow].Cells[HDateCol].Value = oDate.MC1.SelectionEnd.ToShortDateString(); oEdit.Text = oDate.MC1.SelectionEnd.ToShortDateString(); } } //ÉèÖÃÍø¸ñ²Ö¿â public static void SetGridWarehouse(Int64 HWhID, DataGridView grdMain, int HMaterIDCol, int HWHIDCol, int HWHNameCol, int HWHNumberCol) { if (HWhID == 0) { return; } DAL.ClsGy_Warehouse_View oWH = new DAL.ClsGy_Warehouse_View(); if (oWH.GetInfoByID(HWhID)) { for (int i = 0; i < grdMain.Rows.Count; i++) { if (ClsPub.isLong(grdMain.Rows[i].Cells[HMaterIDCol].Value) != 0) { grdMain.Rows[i].Cells[HWHIDCol].Value = oWH.omodel.HItemID; grdMain.Rows[i].Cells[HWHNameCol].Value = oWH.omodel.HName; grdMain.Rows[i].Cells[HWHNumberCol].Value = oWH.omodel.HNumber; } } } } /// /// ¸ù¾Ý±íÍ·²Ö¿â£¬ÉèÖÃÍø¸ñ²Ö¿â /// /// ²Ö¿âid /// /// ÎïÁÏidÁÐ /// ÐкŠ/// ²Ö¿âidÁÐ /// ²Ö¿âÃû³ÆÁÐ /// ²Ö¿â´úÂëÁÐ public static void SetGridWarehouse(Int64 HWhID, DataGridView grdMain, int HMaterIDCol, int i, int HWHIDCol, int HWHNameCol, int HWHNumberCol) { if (HWhID == 0) { return; } DAL.ClsGy_Warehouse_View oWH = new DAL.ClsGy_Warehouse_View(); if (oWH.GetInfoByID(HWhID)) { grdMain.Rows[i].Cells[HWHIDCol].Value = oWH.omodel.HItemID; grdMain.Rows[i].Cells[HWHNameCol].Value = oWH.omodel.HName; grdMain.Rows[i].Cells[HWHNumberCol].Value = oWH.omodel.HNumber; } } /// /// ¸ù¾Ý±íÍ·²Ö¿â£¬ÉèÖÃÍø¸ñ²Ö¿â /// /// ²Ö¿âid /// /// ÎïÁÏidÁÐ /// ÐкŠ/// ²Ö¿âidÁÐ /// ²Ö¿âÃû³ÆÁÐ /// ²Ö¿â´úÂëÁÐ public static void SetGridWarehouse_K3(Int64 HWhID, DataGridView grdMain, int HMaterIDCol, int i, int HWHIDCol, int HWHNameCol, int HWHNumberCol) { if (HWhID == 0) { return; } DAL.ClsIF_Warehouse_View oWH = new DAL.ClsIF_Warehouse_View(); if (oWH.GetInfoByID(HWhID)) { grdMain.Rows[i].Cells[HWHIDCol].Value = oWH.omodel.HItemID; grdMain.Rows[i].Cells[HWHNameCol].Value = oWH.omodel.HName; grdMain.Rows[i].Cells[HWHNumberCol].Value = oWH.omodel.HNumber; } } /// /// ¸ù¾Ý±íÍ·ÐéÄâ²Ö¿â£¬ÉèÖÃÍø¸ñ²Ö¿â /// /// ²Ö¿âid /// /// ÎïÁÏidÁÐ /// ÐкŠ/// ²Ö¿âidÁÐ /// ²Ö¿âÃû³ÆÁÐ /// ²Ö¿â´úÂëÁÐ public static void SetGridVirtualWarehouse(Int64 HWhID, DataGridView grdMain, int HMaterIDCol, int HWHIDCol, int HWHNameCol, int HWHNumberCol) { if (HWhID == 0) { return; } DAL.ClsGy_VirtualWarehouse_View oWH = new DAL.ClsGy_VirtualWarehouse_View(); if (oWH.GetInfoByID(HWhID)) { for (int i = 0; i < grdMain.Rows.Count; i++) { if (ClsPub.isLong(grdMain.Rows[i].Cells[HMaterIDCol].Value) != 0) { grdMain.Rows[i].Cells[HWHIDCol].Value = oWH.omodel.HItemID; grdMain.Rows[i].Cells[HWHNameCol].Value = oWH.omodel.HName; grdMain.Rows[i].Cells[HWHNumberCol].Value = oWH.omodel.HNumber; } } } } public static void SetGridVirtualWarehouse(Int64 HWhID, DataGridView grdMain, int HMaterIDCol, int i, int HWHIDCol, int HWHNameCol, int HWHNumberCol) { if (HWhID == 0) { return; } DAL.ClsGy_VirtualWarehouse_View oWH = new DAL.ClsGy_VirtualWarehouse_View(); if (oWH.GetInfoByID(HWhID)) { grdMain.Rows[i].Cells[HWHIDCol].Value = oWH.omodel.HItemID; grdMain.Rows[i].Cells[HWHNameCol].Value = oWH.omodel.HName; grdMain.Rows[i].Cells[HWHNumberCol].Value = oWH.omodel.HNumber; } } //»ñÈ¡ÁÐ±í ºÏ¼ÆÁÐ public static string GetTotalCols(DataSet DSet) { string sTotalCol = ""; for (int i = 0; i < DSet.Tables[0].Columns.Count; i++) { if (DSet.Tables[0].Columns[i].DataType == Type.GetType("System.Double")) { sTotalCol = sTotalCol + "," + i.ToString(); } else if (DSet.Tables[0].Columns[i].DataType == Type.GetType("System.Single")) { sTotalCol = sTotalCol + "," + i.ToString(); } else if (DSet.Tables[0].Columns[i].DataType == Type.GetType("System.Int16")) { sTotalCol = sTotalCol + "," + i.ToString(); } else if (DSet.Tables[0].Columns[i].DataType == Type.GetType("System.Int32")) { sTotalCol = sTotalCol + "," + i.ToString(); } else if (DSet.Tables[0].Columns[i].DataType == Type.GetType("System.Int64")) { sTotalCol = sTotalCol + "," + i.ToString(); } else if (DSet.Tables[0].Columns[i].DataType == Type.GetType("System.Decimal")) { sTotalCol = sTotalCol + "," + i.ToString(); } else if (DSet.Tables[0].Columns[i].DataType == Type.GetType("System.String")) { sTotalCol = sTotalCol + "," + i.ToString(); } } if (sTotalCol != "") { sTotalCol = sTotalCol.Substring(1, sTotalCol.Length - 1); } return sTotalCol; } //Òý³öEXCEL public static void DataToExcel(DataGridView grdMain) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Excel(*.xls)|*.xls|Excel(*.xlsx)|*.xlsx"; //saveFileDialog.Filter = "ExeclÎļþ(*.xls)|*.xls"; saveFileDialog.FilterIndex = 0; saveFileDialog.RestoreDirectory = true; saveFileDialog.CreatePrompt = true; saveFileDialog.Title = "Êý¾ÝÊÓͼµ¼³öEXCELÎļþ"; saveFileDialog.ShowDialog(); Stream myStream; myStream = saveFileDialog.OpenFile(); StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding("gb2312")); string str = ""; DateTime start = DateTime.Now; try { //д±êÌâ for (int i = 0; i < grdMain.ColumnCount; i++) { if (i > 0) { str += "\t"; } str += grdMain.Columns[i].HeaderText; } sw.WriteLine(str); //дÄÚÈÝ for (int j = 0; j < grdMain.Rows.Count; j++) { string tempStr = ""; for (int k = 0; k < grdMain.Columns.Count; k++) { if (k > 0) { tempStr += "\t"; } if (grdMain.Rows[j].Cells[k].Value == null) { tempStr += string.Empty; } else { tempStr += grdMain.Rows[j].Cells[k].Value.ToString(); } } sw.WriteLine(tempStr); } sw.Close(); myStream.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sw.Close(); myStream.Close(); } MessageBox.Show("½«´Ë¹¤×÷±íµ¼³öΪexcel¹²ºÄʱ£º" + DateTime.Now.Subtract(start).TotalMilliseconds.ToString() + "ºÁÃë"); } //Ñ¡ÔñÈÕÆÚ¿ò /// /// Ñ¡ÔñÈÕÆÚ¿ò /// /// public static void Sub_SelectDate_ALL(DataGridView grd, int iRow, int HDateCol, int HKeyCol) { FrmSelectDate oDate = new FrmSelectDate(); oDate.ShowDialog(); if (oDate.isSelected == true) { for (int i = 0; i < grd.Rows.Count; i++) { if (DBUtility.ClsPub.isDate(grd.Rows[i].Cells[HDateCol].Value) <= Convert.ToDateTime("1960-01-01") && DBUtility.ClsPub.isLong(grd.Rows[i].Cells[HKeyCol].Value) != 0) { grd.Rows[i].Cells[HDateCol].Value = oDate.MC1.SelectionStart.ToShortDateString(); grd.Rows[i].Cells[HDateCol].Value = oDate.MC1.SelectionEnd.ToShortDateString(); } } } grd.Rows[iRow].Cells[HDateCol].Value = oDate.MC1.SelectionStart.ToShortDateString(); grd.Rows[iRow].Cells[HDateCol].Value = oDate.MC1.SelectionEnd.ToShortDateString(); } //µÃµ½ÎïÁÏ ²É¹ºµ¥¼Û /// /// µÃµ½ÎïÁÏ ²É¹ºµ¥¼Û /// /// /// /// /// /// /// /// public static void SetGridMaterProPrice(Int64 HSupID, DateTime HDate, int HQtyCol, DataGridView grdMain, int iRow, int HMaterIDCol, int HPriceCol, int HTaxRateCol) { try { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet ds; Int64 HMaterID = ClsPub.isLong(grdMain.Rows[iRow].Cells[HMaterIDCol].Value); double HQty = ClsPub.isLong(grdMain.Rows[iRow].Cells[HQtyCol].Value); ds = oCn.RunProcReturn("exec h_p_Gy_GetMaterProPrice "+HMaterID.ToString()+","+HSupID.ToString()+",'"+HDate.ToShortDateString()+"',"+HQty.ToString(), "gy_czygl"); if (ds == null || ds.Tables[0].Rows.Count == 0) { // } else { grdMain.Rows[iRow].Cells[HPriceCol].Value = ClsPub.isDoule(ds.Tables[0].Rows[0]["µ¥¼Û"], 4); //grdMain.Rows[iRow].Cells[HTaxRateCol].Value = ClsPub.isDoule(ds.Tables[0].Rows[0]["˰ÂÊ"], 2); } grdMain.Rows[iRow].Cells[HTaxRateCol].Value = "17"; } catch (Exception e) { MessageBox.Show("»ñÈ¡µ¥¼Ûʧ°Ü£¡"); return; } } //µÃµ½ÎïÁÏ ²É¹ºµ¥¼Û /// /// µÃµ½ÎïÁÏ ²É¹ºµ¥¼Û /// /// /// /// /// /// /// /// public static void SetGridMaterProPrice(Int64 HSupID, DateTime HDate, int HQtyCol, DataGridView grdMain, int iRow, int HMaterIDCol, int HPriceCol) { try { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet ds; Int64 HMaterID = ClsPub.isLong(grdMain.Rows[iRow].Cells[HMaterIDCol].Value); double HQty = ClsPub.isLong(grdMain.Rows[iRow].Cells[HQtyCol].Value); ds = oCn.RunProcReturn("exec h_p_Gy_GetMaterProPrice " + HMaterID.ToString() + "," + HSupID.ToString() + ",'" + HDate.ToShortDateString() + "'," + HQty.ToString(), "gy_czygl"); if (ds == null || ds.Tables[0].Rows.Count == 0) { // } else { grdMain.Rows[iRow].Cells[HPriceCol].Value = ClsPub.isDoule(ds.Tables[0].Rows[0]["µ¥¼Û"], 4); //grdMain.Rows[iRow].Cells[HTaxRateCol].Value = ClsPub.isDoule(ds.Tables[0].Rows[0]["˰ÂÊ"], 2); } } catch (Exception e) { MessageBox.Show("»ñÈ¡µ¥¼Ûʧ°Ü£¡"); return; } } //µÃµ½ÎïÁÏ ÏúÊÛµ¥¼Û public static void SetGridMaterSelPrice(Int64 HSupID, DateTime HDate, int HQtyCol, DataGridView grdMain, int iRow, int HMaterIDCol, int HPriceCol) { try { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet ds; Int64 HMaterID = ClsPub.isLong(grdMain.Rows[iRow].Cells[HMaterIDCol].Value); double HQty = ClsPub.isLong(grdMain.Rows[iRow].Cells[HQtyCol].Value); ds = oCn.RunProcReturn("exec h_p_Gy_GetMaterSelPrice " + HMaterID.ToString() + "," + HSupID.ToString() + ",'" + HDate.ToShortDateString() + "'," + HQty.ToString(), "gy_czygl"); if (ds == null || ds.Tables[0].Rows.Count == 0) { return; } else { grdMain.Rows[iRow].Cells[HPriceCol].Value = ClsPub.isDoule(ds.Tables[0].Rows[0]["µ¥¼Û"], 4); } } catch (Exception e) { MessageBox.Show("»ñÈ¡µ¥¼Ûʧ°Ü£¡"); return; } } public static void ShowColumns(DataGridView grdMain) { //´Ó±¾µØTXT¶ÁÈ¡ ±¾Ä£¿é ÁÐÏÔʾ״̬ } public static void SetShowColumns() { //±£´æÁÐÏÔʾ״̬µ½ ±¾µØtxt } /// /// »ñȡԴµ¥ÀàÐ͵½×éºÏ¿ò /// /// /// /// public static void GetBillSource(string HBillType, bool HRedBlueFlag, ComboBox cmbSourceBillType) { //»ñȡԭµ¥ÀàÐÍ try { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet ds; ds = oCn.RunProcReturn("select * from Xt_BillSourceSet where HNumber='" + HBillType + "' and HRedBlueFlag=" + DBUtility.ClsPub.BoolToString(HRedBlueFlag), "Xt_BillSourceSet"); if (ds == null || ds.Tables[0].Rows.Count == 0) { return; } else { cmbSourceBillType.Items.Clear(); for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { cmbSourceBillType.Items.Add(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HSourceBillTypeName"])); } //¼ÓÉÏÊÖ¹¤Â¼Èë cmbSourceBillType.Items.Add("ÊÖ¹¤Â¼Èë"); } } catch (Exception e) { MessageBox.Show("»ñȡԴµ¥ÀàÐÍʧ°Ü£¡"+e.Message); return; } } //¼ì²â µ±Ç°Ñ¡ÖÐÐÐµÄ ÏîĿ״̬ public static void Sub_CheckUseStatus(DataGridView grd, int IDCol,string sProcName) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); Int64 sItemID; try { //Ñ­»·µ±Ç°Íø¸ñÑ¡ÖÐÏîÄ¿ for (int i = 0; i < grd.SelectedRows.Count; i++) { //µÃµ½ÄÚÂë sItemID = DBUtility.ClsPub.isLong(grd.Rows[grd.SelectedRows[i].Index].Cells[IDCol].Value); //µ÷Óô¢´æ¹ý³Ì h_p_Gy_CheckUseDept oCn.RunProc("exec " + sProcName + " " + sItemID.ToString(),ref ClsPub.sExeReturnInfo); } } catch (Exception e) { MessageBox.Show("¼ì²â´íÎó£¡Ô­Òò£º" + ClsPub.sExeReturnInfo); } } //½ûÓÃÏîÄ¿ ºìÉ«×ÖÌå public static void Sub_ShowStopFlag(DataGridView grd, int StopFlagCol) { //Ñ­»·µ±Ç°Íø¸ñ for (int i = 0; i < grd.Rows.Count; i++) { if (StopFlagCol< 0) { return; } //Èç¹û ½ûÓñê¼Ç Ϊ ÊÇ£¬Ôò ºìÉ«×ÖÌ壬 ·ñÔò ºÚÉ« if (DBUtility.ClsPub.isStrNull(grd.Rows[i].Cells[StopFlagCol].Value) == "Y") { grd.Rows[i].DefaultCellStyle.ForeColor = Color.Red; } else { grd.Rows[i].DefaultCellStyle.ForeColor = Color.Black; } } } //»ñÈ¡¹¤×÷ÁªÏµµ¥,ĬÈÏÄÚÈÝ public static void GetOA_SendMessage(long HInterID, string HBillType, ref string sReturn) { try { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet ds; DataSet dsMod; DataSet ds1; DataSet ds2; string HSendMessage = ""; //µÃµ½´ø±äÁ¿µÄĬÈÏ·¢ËÍÄÚÈÝ dsMod = oCn.RunProcReturn("select * from OA_WorkLinkBillMod where HBillType='" + HBillType + "' and HUser='" + DBUtility.ClsPub.CurUserName + "'", "OA_WorkLinkBillMod"); if (dsMod == null || dsMod.Tables[0].Rows.Count == 0) { sReturn = ""; return; } HSendMessage = DBUtility.ClsPub.isStrNull(dsMod.Tables[0].Rows[0]["HSendMessage"]); //µÃµ½±äÁ¿¶ÔÓ¦×Ö¶Î ds = oCn.RunProcReturn("select * from OA_FieldToChange where HBillType='" + HBillType + "'", "OA_FieldToChange"); if (ds == null || ds.Tables[0].Rows.Count == 0) { sReturn = ""; return; } else { for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { //µÃµ½»ù´¡×ÊÁÏHItemID , »òÕß ×Ö·û´® ×Ö¶Î ds1 = oCn.RunProcReturn("select " + ds.Tables[0].Rows[i]["HFieldName"] + " from " + ds.Tables[0].Rows[i]["HTableName"] + " where HInterID=" + HInterID.ToString(), ClsPub.isStrNull(ds.Tables[0].Rows[i]["HTableName"])); if (ClsPub.isStrNull(ds.Tables[0].Rows[i]["HType"]) == "»ù´¡×ÊÁÏ") { //¸ù¾Ý»ù´¡×ÊÁÏID,µÃµ½ÐèÒªÏÔʾµÄ×Ö¶Î(Èç:HName) ds2 = oCn.RunProcReturn("select " + ds.Tables[0].Rows[i]["HShowFieldName"] + " from " + ds.Tables[0].Rows[i]["HBaseTable"] + " where HItemID=" + DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0][0]), ClsPub.isStrNull(ds.Tables[0].Rows[i]["HBaseTable"])); //Ìæ»» ĬÈÏ·¢ËÍÄÚÈÝÀïµÄ±äÁ¿ HSendMessage = HSendMessage.Replace(ClsPub.isStrNull(ds.Tables[0].Rows[i]["HText"]), ClsPub.isStrNull(ds2.Tables[0].Rows[0][0])); } else { //Ìæ»» ĬÈÏ·¢ËÍÄÚÈÝÀïµÄ±äÁ¿ HSendMessage = HSendMessage.Replace(ClsPub.isStrNull(ds.Tables[0].Rows[i]["HText"]), ClsPub.isStrNull(ds1.Tables[0].Rows[0][0])); } } } sReturn = HSendMessage; } catch (Exception e) { MessageBox.Show("»ñȡĬÈÏÄÚÈÝʧ°Ü£¡" + e.Message); sReturn = ""; return; } } //»ñÈ¡¹¤×÷ÁªÏµµ¥,ĬÈϽÓÊÕÈË public static void GetOA_ReceiveMan(long HInterID, string HBillType, ref string sReturn) { try { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet ds; string HReceiveMan = ""; //µÃµ½Ä¬ÈϽÓÊÕÈË ds = oCn.RunProcReturn("select * from OA_WorkLinkBillMod where HBillType='" + HBillType + "' and HUser='" + DBUtility.ClsPub.CurUserName + "'", "OA_WorkLinkBillMod"); if (ds == null || ds.Tables[0].Rows.Count == 0) { sReturn = ""; return; } HReceiveMan = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HReceiveMan"]); sReturn = HReceiveMan; } catch (Exception e) { MessageBox.Show("»ñȡĬÈϽÓÊÕÈËʧ°Ü£¡" + e.Message); sReturn = ""; return; } } //ÉèÖÃÍø¸ñÄ£¾ß²Ö¿â public static void SetGridMouldStock(Int64 HMouldStockID, DataGridView grdMain, int HMaterIDCol, int HIDCol, int HNameCol, int HNumberCol) { if (HMouldStockID == 0) { return; } DAL.ClsGy_StockPlace_View oMS = new DAL.ClsGy_StockPlace_View(); if (oMS.GetInfoByID(HMouldStockID)) { for (int i = 0; i < grdMain.Rows.Count; i++) { if (ClsPub.isLong(grdMain.Rows[i].Cells[HMaterIDCol].Value) != 0) { grdMain.Rows[i].Cells[HIDCol].Value = oMS.omodel.HItemID; grdMain.Rows[i].Cells[HNameCol].Value = oMS.omodel.HName; grdMain.Rows[i].Cells[HNumberCol].Value = oMS.omodel.HNumber; } } } } /// /// ¸ù¾Ý±íÍ·²Ö¿â£¬ÉèÖÃÍø¸ñÄ£¾ß²Ö¿â /// /// ²Ö¿âid /// /// ÎïÁÏidÁÐ /// ÐкŠ/// ²Ö¿âidÁÐ /// ²Ö¿âÃû³ÆÁÐ /// ²Ö¿â´úÂëÁÐ public static void SetGridMouldStock(Int64 HWhID, DataGridView grdMain, int HMaterIDCol, int i, int HWHIDCol, int HWHNameCol, int HWHNumberCol) { if (HWhID == 0) { return; } DAL.ClsIF_MouldStock_View oWH = new DAL.ClsIF_MouldStock_View(); if (oWH.GetInfoByID(HWhID)) { grdMain.Rows[i].Cells[HWHIDCol].Value = oWH.omodel.HItemID; grdMain.Rows[i].Cells[HWHNameCol].Value = oWH.omodel.HName; grdMain.Rows[i].Cells[HWHNumberCol].Value = oWH.omodel.HNumber; } } /// /// ¸ù¾Ý±íÍ·²Ö¿â£¬ÉèÖÃÍø¸ñ²Ö¿â /// /// ²Ö¿âid /// /// ÎïÁÏidÁÐ /// ÐкŠ/// ²Ö¿âidÁÐ /// ²Ö¿âÃû³ÆÁÐ /// ²Ö¿â´úÂëÁÐ public static void SetGridWarehouse_IF(Int64 HWhID, DataGridView grdMain, int HMaterIDCol, int i, int HWHIDCol, int HWHNameCol, int HWHNumberCol) { if (HWhID == 0) { return; } DAL.ClsIF_Warehouse_View oWH = new DAL.ClsIF_Warehouse_View(); if (oWH.GetInfoByID(HWhID)) { grdMain.Rows[i].Cells[HWHIDCol].Value = oWH.omodel.HItemID; grdMain.Rows[i].Cells[HWHNameCol].Value = oWH.omodel.HName; grdMain.Rows[i].Cells[HWHNumberCol].Value = oWH.omodel.HNumber; } } //¸ù¾Ý±íÍ· »ØÌî±íÌå Íø¸ñ²Ö¿â public static void SetGridWarehouse_IF(Int64 HWhID, DataGridView grdMain, int HMaterIDCol, int HWHIDCol, int HWHNameCol, int HWHNumberCol) { if (HWhID == 0) { return; } DAL.ClsIF_Warehouse_View oWH = new DAL.ClsIF_Warehouse_View(); if (oWH.GetInfoByID(HWhID)) { for (int i = 0; i < grdMain.Rows.Count; i++) { if (ClsPub.isLong(grdMain.Rows[i].Cells[HMaterIDCol].Value) != 0) { grdMain.Rows[i].Cells[HWHIDCol].Value = oWH.omodel.HItemID; grdMain.Rows[i].Cells[HWHNameCol].Value = oWH.omodel.HName; grdMain.Rows[i].Cells[HWHNumberCol].Value = oWH.omodel.HNumber; } } } } ///// ///// ÉèÖÃÏß״ͼ ±êÇ© ÏßÌõ´Öϸ ///// ///// //public static void SetTeeChartFastLine(Steema.TeeChart.Styles.FastLine oLine) //{ // //±êÇ© // oLine.Marks.Visible = false; //ÊÇ·ñÏÔʾ // oLine.Marks.Style = Steema.TeeChart.Styles.MarksStyles.Value; //Êý¾ÝÀàÐÍ // //ÏßÌõ´Öϸ // oLine.LinePen.Width = 3; //} public static string GetDeptStrByUser() { try { //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //DataSet ds; //if (DBUtility.ClsPub.Security_Log("Gy_UserDeptRelationAll", 1, false, DBUtility.ClsPub.CurUserName)) //{ return "-1"; //} //ds = oCn.RunProcReturn("exec h_p_Gy_UserDeptRelation '" + DBUtility.ClsPub.CurUserName + "'", "gy_czygl"); //if (ds == null || ds.Tables[0].Rows.Count == 0) //{ // return "0"; //} //else //{ // return DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]); //} } catch (Exception e) { MessageBox.Show("»ñȡʧ°Ü£¡" + e.Message); return "0"; } } public static void Sub_RowCount(DataGridView grdMain, int sRow, int sCol, int HQtyCol, int HPriceCol, int HMoneyCol) { double sPrice = 0;//µ¥¼Û double sMoney = 0;//½ð¶î //ÊýÁ¿²»ÄÜΪ0 if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) == 0) { return; } //ÊäÈëÊýÁ¿,µ¥¼Û:Ëã ½ð¶î if (sCol == HQtyCol || sCol == HPriceCol) { //½ð¶î=ÊýÁ¿*µ¥¼Û sMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value); grdMain.Rows[sRow].Cells[HMoneyCol].Value = ClsPub.isDoule(sMoney, 2); } //ÊäÈë½ð¶î£ºËã µ¥¼Û if (sCol == HMoneyCol) { //µ¥¼Û=½ð¶î/ÊýÁ¿ sPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) / ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value); grdMain.Rows[sRow].Cells[HPriceCol].Value = ClsPub.isDoule(sPrice, 4); } } /// /// Íø¸ñ µ¼³öEXCEL /// public static void DataGridViewToExcel2(DataGridView grdMain,string sText) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "ExeclÎļþ(*.xls)|*.xls"; saveFileDialog.FilterIndex = 0; saveFileDialog.RestoreDirectory = true; saveFileDialog.CreatePrompt = true; saveFileDialog.Title = "Êý¾ÝÊÓͼµ¼³öEXCELÎļþ"; saveFileDialog.FileName = sText; saveFileDialog.ShowDialog(); Stream myStream; myStream = saveFileDialog.OpenFile(); StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding("gb2312")); string str = ""; DateTime start = DateTime.Now; try { //д±êÌâ for (int i = 0; i < grdMain.ColumnCount; i++) { if (i > 0) { str += "\t"; } str += grdMain.Columns[i].HeaderText; } sw.WriteLine(str); //дÄÚÈÝ for (int j = 0; j < grdMain.Rows.Count; j++) { string tempStr = ""; for (int k = 0; k < grdMain.Columns.Count; k++) { if (k > 0) { tempStr += "\t"; } if (grdMain.Rows[j].Cells[k].Value == null) { tempStr += string.Empty; } else { tempStr += grdMain.Rows[j].Cells[k].Value.ToString(); } } sw.WriteLine(tempStr); } sw.Close(); myStream.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { sw.Close(); myStream.Close(); } MessageBox.Show("½«´Ë¹¤×÷±íµ¼³öΪexcel¹²ºÄʱ£º" + DateTime.Now.Subtract(start).TotalMilliseconds.ToString() + "ºÁÃë"); } public static void Sub_RowCount(DataGridView grdMain, int sRow, int sCol, int HQtyCol, int HPriceCol, int HMoneyCol, int HTaxRateCol, int HTaxPriceCol , int HDiscountRateCol, int HRelTaxPriceCol, int HTaxMoneyCol, int HlineTotalCol, int HlineTotalBBCol) { double sPrice = 0;//µ¥¼Û double sTaxPrice = 0; //º¬Ë°µ¥¼Û double sMoney = 0;//½ð¶î double sTaxMoney = 0;//˰¶î double sRelTaxPrice = 0; //ʵ¼Êº¬Ë°µ¥¼Û double slineTotal = 0;//¼Û˰ºÏ¼Æ //ÕÛ¿ÛÂÊ ´óÓÚ0 СÓÚ1 if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value) <= 0 || ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value) >= 1) { grdMain.Rows[sRow].Cells[HDiscountRateCol].Value = 1; } //˰ÂÊ ´óÓÚ=0 СÓÚµÈÓÚ100 if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value) < 0 || ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value) > 100) { grdMain.Rows[sRow].Cells[HTaxRateCol].Value = 0; } //ÊýÁ¿²»ÄÜΪ0 if (ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) ==0) { return; } //ÊäÈëÊýÁ¿,µ¥¼Û:Ëã º¬Ë°µ¥¼Û£¬½ð¶î£¬Êµ¼Êº¬Ë°µ¥¼Û£¬Õۿ۶˰¶î£¬¼Û˰ºÏ¼Æ,¼Û˰ºÏ¼Æ±¾Î»±Ò if (sCol == HQtyCol || sCol == HPriceCol) { //º¬Ë°µ¥¼Û=µ¥¼Û*(1+˰ÂÊ) sTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HPriceCol].Value) * (100 + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value)) / 100.00; grdMain.Rows[sRow].Cells[HTaxPriceCol].Value = ClsPub.isDoule(sTaxPrice, 4); //½ð¶î=ÊýÁ¿*µ¥¼Û sMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value); grdMain.Rows[sRow].Cells[HMoneyCol].Value = ClsPub.isDoule(sMoney, 2); //ʵ¼Êº¬Ë°µ¥¼Û=º¬Ë°µ¥¼Û*ÕÛ¿ÛÂÊ sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); ////ÕÛ¿Û¶î=º¬Ë°µ¥¼Û*(1-ÕÛ¿ÛÂÊ)*ÊýÁ¿ //sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); //grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); //˰¶î=½ð¶î*˰ÂÊ sTaxMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value) / 100; grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value = ClsPub.isDoule(sTaxMoney, 2); //ºÏ¼Æ=˰¶î+½ð¶î slineTotal = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value); grdMain.Rows[sRow].Cells[HlineTotalCol].Value = ClsPub.isDoule(slineTotal, 2); } //ÊäÈ뺬˰µ¥¼Û£ºËã µ¥¼Û£¬½ð¶î£¬Êµ¼Êº¬Ë°µ¥¼Û£¬Õۿ۶˰¶î£¬¼Û˰ºÏ¼Æ if (sCol == HTaxPriceCol) { //µ¥¼Û=º¬Ë°µ¥¼Û/(1+˰ÂÊ) sPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) /((100 + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value)) / 100.00); grdMain.Rows[sRow].Cells[HPriceCol].Value = ClsPub.isDoule(sPrice, 4); //½ð¶î=ÊýÁ¿*µ¥¼Û sMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value); grdMain.Rows[sRow].Cells[HMoneyCol].Value = ClsPub.isDoule(sMoney, 2); //ʵ¼Êº¬Ë°µ¥¼Û=º¬Ë°µ¥¼Û*ÕÛ¿ÛÂÊ sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); ////ÕÛ¿Û¶î=º¬Ë°µ¥¼Û*(1-ÕÛ¿ÛÂÊ)*ÊýÁ¿ //sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); //grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); //˰¶î=½ð¶î*˰ÂÊ sTaxMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value) / 100; grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value = ClsPub.isDoule(sTaxMoney, 2); //ºÏ¼Æ=˰¶î+½ð¶î slineTotal = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value); grdMain.Rows[sRow].Cells[HlineTotalCol].Value = ClsPub.isDoule(slineTotal, 2); } //ÊäÈë½ð¶î£ºËã µ¥¼Û£¬º¬Ë°µ¥¼Û£¬Êµ¼Êº¬Ë°µ¥¼Û£¬Õۿ۶˰¶î£¬¼Û˰ºÏ¼Æ if (sCol == HMoneyCol) { //µ¥¼Û=½ð¶î/ÊýÁ¿ sPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) / ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value); grdMain.Rows[sRow].Cells[HPriceCol].Value = ClsPub.isDoule(sPrice, 4); //º¬Ë°µ¥¼Û=µ¥¼Û*(1+˰ÂÊ) sTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HPriceCol].Value) * (100 + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value)) / 100.00; grdMain.Rows[sRow].Cells[HTaxPriceCol].Value = ClsPub.isDoule(sTaxPrice, 4); //ʵ¼Êº¬Ë°µ¥¼Û=º¬Ë°µ¥¼Û*ÕÛ¿ÛÂÊ sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); ////ÕÛ¿Û¶î=º¬Ë°µ¥¼Û*(1-ÕÛ¿ÛÂÊ)*ÊýÁ¿ //sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); //grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); //˰¶î=½ð¶î*˰ÂÊ sTaxMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value) / 100; grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value = ClsPub.isDoule(sTaxMoney, 2); //ºÏ¼Æ=˰¶î+½ð¶î slineTotal = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value); grdMain.Rows[sRow].Cells[HlineTotalCol].Value = ClsPub.isDoule(slineTotal, 2); } //ÊäÈë˰ÂÊ£ºËã º¬Ë°µ¥¼Û£¬Êµ¼Êº¬Ë°µ¥¼Û£¬Õۿ۶˰¶î£¬¼Û˰ºÏ¼Æ if (sCol == HTaxRateCol) { //º¬Ë°µ¥¼Û=µ¥¼Û*(1+˰ÂÊ) sTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HPriceCol].Value) * (100 + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value)) / 100.00; grdMain.Rows[sRow].Cells[HTaxPriceCol].Value = ClsPub.isDoule(sTaxPrice, 4); //ʵ¼Êº¬Ë°µ¥¼Û=º¬Ë°µ¥¼Û*ÕÛ¿ÛÂÊ sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); ////ÕÛ¿Û¶î=º¬Ë°µ¥¼Û*(1-ÕÛ¿ÛÂÊ)*ÊýÁ¿ //sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); //grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); //˰¶î=½ð¶î*˰ÂÊ sTaxMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value) / 100; grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value = ClsPub.isDoule(sTaxMoney, 2); //ºÏ¼Æ=˰¶î+½ð¶î slineTotal = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value); grdMain.Rows[sRow].Cells[HlineTotalCol].Value = ClsPub.isDoule(slineTotal, 2); } //ÊäÈëÕÛ¿ÛÂÊ£ºËã ʵ¼Êº¬Ë°µ¥¼Û£¬Õۿ۶˰¶î£¬¼Û˰ºÏ¼Æ if (sCol == HDiscountRateCol) { //ʵ¼Êº¬Ë°µ¥¼Û=º¬Ë°µ¥¼Û*ÕÛ¿ÛÂÊ sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); ////ÕÛ¿Û¶î=º¬Ë°µ¥¼Û*(1-ÕÛ¿ÛÂÊ)*ÊýÁ¿ //sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); //grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); //˰¶î=½ð¶î*˰ÂÊ sTaxMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value) / 100; grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value = ClsPub.isDoule(sTaxMoney, 2); //ºÏ¼Æ=˰¶î+½ð¶î slineTotal = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value); grdMain.Rows[sRow].Cells[HlineTotalCol].Value = ClsPub.isDoule(slineTotal, 2); } //ÊäÈë¼Û˰ºÏ¼Æ£ºËã º¬Ë°µ¥¼Û£¬µ¥¼Û,½ð¶î£¬Êµ¼Êº¬Ë°µ¥¼Û£¬Õۿ۶˰¶î if (sCol == HlineTotalCol) { //º¬Ë°µ¥¼Û=¼Û˰ºÏ¼Æ/ÊýÁ¿ sTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HlineTotalCol].Value) /ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value); grdMain.Rows[sRow].Cells[HTaxPriceCol].Value = ClsPub.isDoule(sTaxPrice, 4); //µ¥¼Û=º¬Ë°µ¥¼Û/(1+˰ÂÊ) sPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) / ((100 + ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value)) / 100.00); grdMain.Rows[sRow].Cells[HPriceCol].Value = ClsPub.isDoule(sPrice, 4); //½ð¶î=ÊýÁ¿*µ¥¼Û sMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value); grdMain.Rows[sRow].Cells[HMoneyCol].Value = ClsPub.isDoule(sMoney, 2); //ʵ¼Êº¬Ë°µ¥¼Û=º¬Ë°µ¥¼Û*ÕÛ¿ÛÂÊ sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); ////ÕÛ¿Û¶î=º¬Ë°µ¥¼Û*(1-ÕÛ¿ÛÂÊ)*ÊýÁ¿ //sRelTaxPrice = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxPriceCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HDiscountRateCol].Value); //grdMain.Rows[sRow].Cells[HRelTaxPriceCol].Value = ClsPub.isDoule(sRelTaxPrice, 4); //˰¶î=½ð¶î*˰ÂÊ sTaxMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMoneyCol].Value) * ClsPub.isDoule(grdMain.Rows[sRow].Cells[HTaxRateCol].Value) / 100; grdMain.Rows[sRow].Cells[HTaxMoneyCol].Value = ClsPub.isDoule(sTaxMoney, 2); } } } }