⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xskdform.cs

📁 医药连锁软件源码,设计说明 需求说明请联系:dighonor@163.com
💻 CS
📖 第 1 页 / 共 2 页
字号:
        private void saveandlist(bool editok)//控件状态控制过程
        {
            textBox1.TabIndex = 1;
            if (editok == true)
            {
                dtShow.ReadOnly = true;
                textBox1.ReadOnly = true;
                textBox2.ReadOnly = true;
                textBox3.ReadOnly = true;
                textBox4.ReadOnly = true;
                textBox5.ReadOnly = true;
                textBox6.ReadOnly = true;
                textBox8.ReadOnly = true;
                textBox9.ReadOnly = true;
                comboBox1.Enabled = false;
                comboBox2.Enabled = false;
                textBox11.ReadOnly = true;
                toolStripButton1.Enabled = true;
                toolStripButton2.Enabled = true;
                toolStripButton3.Enabled = true;
                toolStripButton4.Enabled = true;
                toolStripButton5.Image = xlsb.Properties.Resources.add;
                toolStripButton5.Text = "&A增加";
                toolStripButton6.Text = "&D删除";
                toolStripButton7.Enabled = true;
                toolStripButton8.Enabled = true;
                toolStripButton9.Enabled = true;
                toolStripButton10.Enabled = true;
                toolStripButton11.Enabled = true;
                dtShow.AllowUserToAddRows = false;
               
            }
            else
            {

                dtShow.ReadOnly = false;
                textBox1.ReadOnly = false;
                textBox2.ReadOnly = false;
                textBox3.ReadOnly = false;
                textBox4.ReadOnly = false;
                textBox5.ReadOnly = false;
                textBox6.ReadOnly = false;
                textBox8.ReadOnly = false;
                textBox9.ReadOnly = false;
                comboBox1.Enabled = true;
                comboBox2.Enabled = true;
                textBox11.ReadOnly = false;
                textBox13.Text = "";
                textBox12.Text = "";
                textBox15.Text = "";
                toolStripButton1.Enabled = false;
                toolStripButton2.Enabled = false;
                toolStripButton3.Enabled = false;
                toolStripButton4.Enabled = false;
                toolStripButton5.Image = xlsb.Properties.Resources.save;
                toolStripButton5.Text = "&A保存";
                toolStripButton6.Text = "&D取消";
                toolStripButton7.Enabled = false;
                toolStripButton8.Enabled = false;
                toolStripButton9.Enabled = false;
                toolStripButton10.Enabled = false;
                toolStripButton11.Enabled = false;
                textBox14.Text = main.pMainWin.toolStripStatusLabel2.Text;
            }

        }

        private void toolStripButton6_Click(object sender, EventArgs e)//取消时,查询单状态,显示最前一张未审核的单据
        {
            if (toolStripButton6.Text == "&D取消")
            {
                dtShow.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
                saveandlist(true);
                string strsql = "SELECT dbo.SALPROFS.MD_SaleProofNo, dbo.SALPROFS.MD_InvoiceNo, dbo.SALPROFS.MD_SaleStaff, dbo.SALPROFS.MD_Department, dbo.SALPROFS.MD_SaleDate, dbo.SALPROFS.MD_ClientNo,dbo.SALPROFS.MD_StoreLoc, dbo.SALPROFS.MD_TaxRadio,dbo.SALPROFS.MD_PayStyle, dbo.SALPROFS.MD_PayPeriod,dbo.SALPROFS.MD_TotalSaleMoney, dbo.SALPROFS.MD_TotalTaxMoney,dbo.SALPROFS.MD_TotalMoney, dbo.SALPROFS.MD_TotalProfit,dbo.SALPROFS.MD_Staff, dbo.SALPROFS.MD_Remark, dbo.SALPROFS.MD_CheckFlag, dbo.SALPROFS.MD_BackUpFlag,dbo.SALPROFS.MD_ProofFlag, dbo.SALPROFS.Md_InvoiceMoney,dbo.CLIENT.MD_ClientName, dbo.STAFF.MD_StaffName FROM dbo.SALPROFS INNER JOIN dbo.STAFF ON  dbo.SALPROFS.MD_SaleStaff = dbo.STAFF.MD_StaffNo LEFT OUTER JOIN dbo.CLIENT ON dbo.SALPROFS.MD_ClientNo = dbo.CLIENT.MD_ClientNo WHERE (SALPROFS.MD_CheckFlag = 'N')";
                dbconn(strsql);
                filldata(i);
                
                mxdata(false);
               
            }
            
        }
        private void filldata(int i)//文本框赋值
        {
            if (i <ds.Tables[0].Rows.Count || i == 0)
            {
                label20.Text = ds.Tables[0].Rows[i]["MD_SaleProofNo"].ToString();
                textBox1.Text = ds.Tables[0].Rows[i]["MD_SaleDate"].ToString();
                textBox2.Text = ds.Tables[0].Rows[i]["MD_ClientNo"].ToString();
                textBox3.Text = ds.Tables[0].Rows[i]["MD_ClientName"].ToString();
                textBox4.Text = ds.Tables[0].Rows[i]["MD_InvoiceNo"].ToString();
                textBox5.Text = ds.Tables[0].Rows[i]["MD_PayPeriod"].ToString();
                textBox6.Text = ds.Tables[0].Rows[i]["MD_StaffName"].ToString();
                textBox13.Text = ds.Tables[0].Rows[i]["MD_TotalSaleMoney"].ToString();
                textBox12.Text = ds.Tables[0].Rows[i]["MD_TotalTaxMoney"].ToString();
                textBox15.Text = ds.Tables[0].Rows[i]["MD_TotalMoney"].ToString();
                comboBox1.Text = ds.Tables[0].Rows[i]["MD_PayStyle"].ToString();
                textBox7.Text = ds.Tables[0].Rows[i]["MD_Department"].ToString();
                textBox11.Text = ds.Tables[0].Rows[i]["MD_remark"].ToString();
                comboBox1.Text = ds.Tables[0].Rows[i]["MD_PayStyle"].ToString();
                comboBox2.Text = ds.Tables[0].Rows[i]["MD_StoreLoc"].ToString();
                NumToCHN.NumToCh Totext = new NumToCHN.NumToCh();
                textBox10.Text = Totext.NumToChn(textBox15.Text);
            }
            else
                MessageBox.Show("记录已到顶部或尾部");
        }


        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            
            filldata(++i);
            mxdata(false);
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (i > 1)
                filldata(--i);
            else
            {
                filldata(0);
                MessageBox.Show("记录已到顶部或尾部");
            }
            mxdata(false);

        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)//在dataGridView控件中时,"Enter键代替Tab键
        {
            if (ActiveForm.ActiveControl is DataGridView)
            {
                if (keyData == Keys.Enter)
                {
                    System.Windows.Forms.SendKeys.Send("{tab}");
                    return true;
                }
            }
                return base.ProcessCmdKey(ref msg, keyData);
        }



        private void dtShow_CurrentCellChanged(object sender, EventArgs e)//数量*单价=金额过程
        {
            if (dtShow.CurrentRow!=null)
            {
                if (dtShow.CurrentCell.ColumnIndex == 7 || dtShow.CurrentCell.ColumnIndex == 8)
                {
                    decimal sum = 0;
                    if (dtShow.CurrentRow.Cells[6].Value != DBNull.Value && dtShow.CurrentRow.Cells[7].Value != DBNull.Value)
                    {
                        dtShow.CurrentRow.Cells[8].Value = Convert.ToDecimal(dtShow.CurrentRow.Cells[7].Value) * Convert.ToDecimal(dtShow.CurrentRow.Cells[6].Value);

                        int rowCount = dtShow.Rows.Count;

                        for (int j = 0; j < rowCount - 1; j++)
                        {
                            if (dtShow.Rows[j].Cells[8].Value != DBNull.Value)
                                sum += Convert.ToDecimal(dtShow.Rows[j].Cells[8].Value);
                        }

                        textBox13.Text = Convert.ToDouble(sum).ToString();
                        textBox12.Text = Convert.ToString((Convert.ToDouble(sum) * Convert.ToDouble(textBox9.Text)) / 100);
                        textBox15.Text = Convert.ToString(Convert.ToDouble(textBox13.Text) + Convert.ToDouble(textBox12.Text));
                        NumToCHN.NumToCh Totext = new NumToCHN.NumToCh();
                        textBox10.Text = Totext.NumToChn(textBox15.Text);
                        dt.Rows[dtShow.CurrentRow.Index]["MD_LeftQuantity"] = dtShow.CurrentRow.Cells[8].Value;
                        dt.Rows[dtShow.CurrentRow.Index]["MD_index"] = dtShow.CurrentRow.Index + 1;
                        dt.Rows[dtShow.CurrentRow.Index]["MD_ChangeRate"] = 1;
                        dt.Rows[dtShow.CurrentRow.Index]["MD_TaxPrice"] = Convert.ToDouble(dt.Rows[dtShow.CurrentRow.Index]["MD_Price"]) * ((Convert.ToDouble(textBox9.Text) + 100) / 100);
                    }
                }
            }
        }

        private void comboBox2_TextChanged(object sender, EventArgs e)//选择仓库后及dataGridView中为空时,新增一行
        {
            if (dtShow.CurrentRow== null)
            dt.Rows.Add();
           
        }

            private void dtShow_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)//新增一行时,赋默认值
        {
            if (dtShow.CurrentRow != null)
            {
                dt.Rows[dtShow.CurrentRow.Index]["MD_index"] = 1 + dtShow.CurrentRow.Index;
                dt.Rows[dtShow.CurrentRow.Index]["MD_SaleProofNo"] = label20.Text.Trim().ToString();
            }
        }

        private void dtShow_CellLeave(object sender, DataGridViewCellEventArgs e)//在单价列计算金额同时新增一行
        {
            if (dtShow.CurrentCell.ColumnIndex == 7)
            {
                if (dt.Rows[dtShow.CurrentRow.Index]["MD_GoodsUnit"].ToString().Trim() != "")
                    dt.Rows.Add();
            }
            if (dtShow.CurrentCell.ColumnIndex == 0 && dtShow.CurrentRow.Cells[0].Value == DBNull.Value && toolStripButton6.Text == "&D取消")
                dataGridView1_CellMouseDoubleClick(null, null);
        }

        private void dtShow_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) // 在DataGridView中显示行号
        {
           
                
                using (SolidBrush b = new SolidBrush(this.dtShow.RowHeadersDefaultCellStyle.ForeColor))
                {
                    e.Graphics.DrawString(Convert.ToString(e.RowIndex + 1, System.Globalization.CultureInfo.CurrentUICulture), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
                }
            

        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            filldata(0);
            mxdata(false);
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            filldata(ds.Tables[0].Rows.Count-1);
            mxdata(false);
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
           if (e.KeyChar == 13&&textBox2.Text == ""&&textBox2.ReadOnly==false)
                   textBox2_MouseDoubleClick(null, null);
        }

        private void textBox6_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13 && textBox6.Text == "" && textBox6.ReadOnly ==false)
                textBox6_MouseDoubleClick(null, null);

        }

        private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13 && textBox3.Text == "" && textBox3.ReadOnly == false)
                textBox2_MouseDoubleClick(null, null);
        }
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -