Ovqatlanish tartiboti
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
using CnetSDK.Barcode.Generator.Trial;
using System.Drawing.Imaging;
using PQScan.BarcodeCreator;
using Word = Microsoft.Office.Interop.Word;
namespace ALSkaner
{
public partial class Form1 : Form
{
static OleDbConnection mycon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=baza.mdb; Jet OLEDB:Database Password=Qq1w2e3r4");
public Form1()
{
InitializeComponent();
}
private Word.Document wordDocument;
private Word.Application wordapp;
private Word.Document worddocument;
private void toolStripButton2_Click(object sender, EventArgs e)
{
toolStripTextBox1.ReadOnly = false;
dataGridView1.RowsDefaultCellStyle.BackColor = Color.Bisque;
dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.BlueViolet;
dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None;
dataGridView1.DefaultCellStyle.SelectionBackColor = Color.Green;
dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Yellow;
this.panel4.Location = new System.Drawing.Point(0, 25);
panel4.Width = 1330;
panel4.Height = 700;
panel4.Visible = true;
panel2.Visible = false;
panel7.Visible = false;
}
private void ismSharifOrqaliIzlashToolStripMenuItem_Click(object sender, EventArgs e)
{
bazaBindingSource.Filter = "FIO like '%" + toolStripTextBox1.Text + "%'";
}
private void toolStripButton6_Click(object sender, EventArgs e)
{
toolStripTextBox1.ReadOnly = false;
dataGridView1.RowsDefaultCellStyle.BackColor = Color.Bisque;
dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.BlueViolet;
dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None;
dataGridView1.DefaultCellStyle.SelectionBackColor = Color.Green;
dataGridView1.DefaultCellStyle.SelectionForeColor = Color.Yellow;
this.panel4.Location = new System.Drawing.Point(0, 25);
panel4.Width = 1330;
panel4.Height = 700;
panel4.Visible = true;
panel2.Visible = false;
panel7.Visible = false;
}
public void SearchAndReplace(string search, string replace)
{
Object unit = Word.WdUnits.wdStory;
Object extend = Word.WdMovementType.wdMove;
wordapp.Selection.HomeKey(ref unit, ref extend);
Word.Find fnd = wordapp.Selection.Find;
fnd.ClearFormatting();
fnd.Text = search;
fnd.Replacement.ClearFormatting();
fnd.Replacement.Text = replace;
ExecuteReplace(fnd);
}
private Boolean ExecuteReplace(Word.Find find)
{
return ExecuteReplace(find, Word.WdReplace.wdReplaceOne);
}
private Boolean ExecuteReplace(Word.Find find,
Object replaceOption)
{
Object findText = Type.Missing;
Object matchCase = Type.Missing;
Object matchWholeWord = Type.Missing;
Object matchWildcards = Type.Missing;
Object matchSoundsLike = Type.Missing;
Object matchAllWordForms = Type.Missing;
Object forward = Type.Missing;
Object wrap = Type.Missing;
Object format = Type.Missing;
Object replaceWith = Type.Missing;
Object replace = replaceOption;
Object matchKashida = Type.Missing;
Object matchDiacritics = Type.Missing;
Object matchAlefHamza = Type.Missing;
Object matchControl = Type.Missing;
return find.Execute(ref findText, ref matchCase,
ref matchWholeWord, ref matchWildcards, ref matchSoundsLike,
ref matchAllWordForms, ref forward, ref wrap, ref format,
ref replaceWith, ref replace, ref matchKashida,
ref matchDiacritics, ref matchAlefHamza, ref matchControl);
}
string sh,fio,gr,kun,aa,bb,ras,er,ku,ke,day;
int ovv, pos, g;
private void Form1_Load(object sender, EventArgs e)
{
day = DateTime.Now.Date.ToString();
label9.Text = dateTimePicker1.Value.ToShortDateString();
this.jadvalTableAdapter1.Fill(this.bazaDataSet4.Jadval);
this.guruhTableAdapter.Fill(this.bazaDataSet3.guruh);
this.JadvalTableAdapter.Fill(this.bazaDataSet2.Jadval);
this.reportViewer1.RefreshReport();
this.panel2.Location = new System.Drawing.Point(0, 25);
this.panel2.Size = new System.Drawing.Size(1500, 800);
this.richTextBox2.Location = new System.Drawing.Point(312, 234);
this.richTextBox2.Size = new System.Drawing.Size(581, 334);
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.bazaTableAdapter.Fill(this.bazaDataSet1.baza);
a1 = dateTimePicker1.Value.ToShortDateString() + " 00:00:00";
a = Convert.ToDateTime(a1);
jadvalBindingSource1.Filter = "[Nonushta]='" + "N" + "'and [sana]>='" + a + "'";
textBox6.Text = dataGridView2.RowCount.ToString();
jadvalBindingSource1.Filter = "[Tushlik]='" + "T" + "'and [sana]>='" + a + "'";
textBox7.Text = dataGridView2.RowCount.ToString();
jadvalBindingSource1.Filter = "[Kechki_ovqat]='" + "K" + "' and [sana]>='" + a + "'";
textBox8.Text = dataGridView2.RowCount.ToString();
timer1.Enabled = true;
timer1.Start();
textBox1.Focus();
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
comboBox2.Enabled = true;
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
comboBox2.Enabled = false;
}
int co,j;
private void button2_Click(object sender, EventArgs e)
{
try
{
if (radioButton2.Checked)
{
bazaBindingSource.Filter = "Guruh like '%" + comboBox2.SelectedValue.ToString() + "%'";
this.bazaTableAdapter.Fill(this.bazaDataSet1.baza);
}
j=0;
co= dataGridView1.RowCount;
wordapp = new Word.Application();
wordapp.Visible = true;
Object template = Type.Missing;
Object newTemplate = false;
Object documentType = Word.WdNewDocumentType.wdNewBlankDocument;
Object visible = true;
template = Application.StartupPath + @"\Shablon\A_G.doc";
worddocument = wordapp.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);
worddocument.ActiveWindow.Selection.WholeStory();
worddocument.Tables[1].Select();
worddocument.ActiveWindow.Selection.Copy();
for (int i = 0; i < co; i++)
{
worddocument.ActiveWindow.Selection.Paste();
}
Object fileName = (Application.StartupPath + @"\Word\" + comboBox2.SelectedValue.ToString()).Trim().ToString();
Object fileFormat = Word.WdSaveFormat.wdFormatDocument;
Object lockComments = false;
Object password = "";
Object addToRecentFiles = false;
Object writePassword = "";
Object readOnlyRecommended = false;
Object embedTrueTypeFonts = false;
worddocument.SaveAs(ref fileName,
ref fileFormat, ref lockComments,
ref password, ref addToRecentFiles, ref writePassword,
ref readOnlyRecommended, ref embedTrueTypeFonts,
ref saveNativePictureFormat, ref saveFormsData,
ref saveAsAOCELetter, ref encoding, ref insertLineBreaks,
ref allowSubstitutions, ref lineEnding, ref addBiDiMarks);
Object confirmConversions = true;
Object readOnly = false;
Object passwordDocument = Type.Missing;
Object passwordTemplate = Type.Missing;
Object revert = false;
Object writePasswordDocument = Type.Missing;
Object writePasswordTemplate = Type.Missing;
Object format = Type.Missing;
Object oVisible = Type.Missing;
Object openConflictDocument = Type.Missing;
Object openAndRepair = Type.Missing;
Object documentDirection = Type.Missing;
Object noEncodingDialog = false;
Object xmlTransform = Type.Missing;
Microsoft.Office.Interop.Word.Range docRange;
Microsoft.Office.Interop.Word.InlineShape pictureShape;
string imageName;
docRange = worddocument.Tables[1].Rows[1].Cells[1].Range;
docRange.Text = "Maxsus kod";
docRange = worddocument.Tables[1].Rows[1].Cells[2].Range;
docRange.Text = "Familiyasi, ismi, otasining ismi";
docRange = worddocument.Tables[1].Rows[1].Cells[3].Range;
docRange.Text = "Guruh";
docRange = worddocument.Tables[1].Rows[1].Cells[4].Range;
docRange.Text = "Shtrixkod";
for (int i = 2; i <= co+1; i++)
{
s = dataGridView1.Rows[j].Cells[1].FormattedValue.ToString();//nom
button1_Click(sender, e);
docRange = worddocument.Tables[1].Rows[i].Cells[1].Range;
docRange.Text = dataGridView1.Rows[j].Cells[1].FormattedValue.ToString();
docRange = worddocument.Tables[1].Rows[i].Cells[2].Range;
docRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
docRange.Text = dataGridView1.Rows[j].Cells[2].FormattedValue.ToString();//nom
docRange = worddocument.Tables[1].Rows[i].Cells[3].Range;
docRange.Text = dataGridView1.Rows[j].Cells[3].FormattedValue.ToString(); //nom
imageName = @"D:\ALSkaner\Picture.jpg";
docRange = worddocument.Tables[1].Rows[i].Cells[4].Range;
pictureShape = docRange.InlineShapes.AddPicture(imageName);
j++;
}
worddocument.Save();
worddocument.Close();
wordapp.Quit();
}
catch { MessageBox.Show("Xatolik mavjud tekshitib ko`ring!!!"); }
}
Do'stlaringiz bilan baham: |