private void Employees_Load(object sender, EventArgs e) { SetComponentsByPermisions(); this.dtDepartments = Department.GetDepartmentsAsDataTable(this.cnConnection); this.dgvDepartments.DataSource = this.dtDepartments; this.dtCategories = Category.GetCategoriesAsDataTable(this.cnConnection); this.dgvCategories.DataSource = this.dtCategories; this.ciCoInformation = FamSetting.GetCoInformation(this.cnConnection); this.tbName.Text = this.ciCoInformation.strName; this.cbTypes.SelectedItem = this.ciCoInformation.strCoType; if (this.ciCoInformation.dtRegister.Year != 1) { this.dtpRegister.Value = this.ciCoInformation.dtRegister; } this.tbRegisterNumber.Text = this.ciCoInformation.strRegisterCode; this.tbCoID.Text = this.ciCoInformation.strCoID; this.tbAddress.Text = this.ciCoInformation.strAddress; this.tbPostalCode.Text = this.ciCoInformation.strPostalCode; this.tbTell.Text = this.ciCoInformation.strTell; this.tbFax.Text = this.ciCoInformation.strFax; this.tbTaxID.Text = this.ciCoInformation.strTaxID; this.tbProvince.Text = this.ciCoInformation.strProvince; this.tbCity.Text = this.ciCoInformation.strCity; this.tbWebSite.Text = this.ciCoInformation.strWebSite; this.btmCoSave.Enabled = false; }
private void Login_Load(object sender, EventArgs e) { this.frmManagement = (Management)this.Owner; if (FamSetting.GetSaveUserName(this.setSettings.strXmlPath)) { this.CbSaveUserName.Checked = true; this.tbCoId.Text = FamSetting.GetLastUserName(this.setSettings.strXmlPath); } }
public Management() { InitializeComponent(); this.strXmlPath = String.Format(@"c:\Settings.xml"); this.cnConnection = new Connection(); this.usLogined = new User(); this.emLogined = new Employee(); this.setSettings = new FamSetting(); }
private void Management_Load(object sender, EventArgs e) { if (CheckApplicationStatus()) { this.setSettings = new FamSetting(this.cnConnection, this.strXmlPath); this.setSettings.strAppVersion = "1.6.20"; this.staVersion.Text = this.setSettings.strAppVersion; this.Text += String.Format(" - {0}", FamSetting.GetCoInformation(this.cnConnection).strName); } else { this.menLogIn.Enabled = false; } }
private void BtmCoSave_Click(object sender, EventArgs e) { this.ciCoInformation = new FamSetting.CoInformation(); this.ciCoInformation.strName = this.tbName.Text.Trim(); this.ciCoInformation.strCoType = this.cbTypes.SelectedItem.ToString(); this.ciCoInformation.dtRegister = (DateTime)this.dtpRegister.Value; this.ciCoInformation.strRegisterCode = this.tbRegisterNumber.Text.Trim(); this.ciCoInformation.strCoID = this.tbCoID.Text.Trim(); this.ciCoInformation.strAddress = this.tbAddress.Text.Trim(); this.ciCoInformation.strPostalCode = this.tbPostalCode.Text.Trim(); this.ciCoInformation.strTell = this.tbTell.Text.Trim(); this.ciCoInformation.strFax = this.tbFax.Text.Trim(); this.ciCoInformation.strTaxID = this.tbTaxID.Text.Trim(); this.ciCoInformation.strProvince = this.tbProvince.Text.Trim(); this.ciCoInformation.strCity = this.tbCity.Text.Trim(); this.ciCoInformation.strWebSite = this.tbWebSite.Text.Trim(); FamSetting.SetCoInformation(this.cnConnection, this.ciCoInformation); this.btmCoSave.Enabled = false; }
private void btmOk_Click(object sender, EventArgs e) { if (tbCoId.Text == "" || tbPassword.Text == "") { this.labMessage.ForeColor = Color.Red; this.labMessage.Text = "لطفا نام کاربری و رمز ورود را وارد کنید. "; } else { using (UnitOfWork db = new UnitOfWork()) { if (this.CbSaveUserName.Checked) { FamSetting.SetLastUserName(this.setSettings.strXmlPath, this.tbCoId.Text); } var employees = db.Employees.GetEntity(t => t.nvcCoID == tbCoId.Text && t.nvcPassword == tbPassword.Text); if (employees != null) { employees.bitLogined = true; db.Save(); frmManagement.staUser.Text = employees.nvcFirstname + " " + employees.nvcLastname; SetApplicationFacilities(employees.intPost, employees.intDepartment, employees.intSubDepartment); this.frmManagement.menLogIn.Enabled = false; this.frmManagement.menLogOut.Enabled = true; this.Close(); } else { this.labMessage.ForeColor = Color.Red; this.labMessage.Text = "کارمندی با این مشخصات یافت نشد. "; } } } //User.AccountStatus usUserStatus = User.GetAccountStatus(this.cnConnection, this.tbCoId.Text, this.tbPassword.Text); //switch (usUserStatus) //{ // case User.AccountStatus.AccountIsReady: // User.Login(this.cnConnection, ref this.usLogined, this.tbCoId.Text, this.tbPassword.Text); // Employee.GetByCoID(this.cnConnection, this.usLogined.strCoID, this.emLogined); // this.frmManagement.staUser.Text = this.emLogined.strName; // SetApplicationFacilities(); // if (this.CbSaveUserName.Checked) // { // FamSetting.SetLastUserName(this.setSettings.strXmlPath, this.tbCoId.Text); // } // this.frmManagement.menLogIn.Enabled = false; // this.frmManagement.menLogOut.Enabled = true; // this.Close(); // break; // case User.AccountStatus.AccountAlreadyLogined: // this.labMessage.ForeColor = Color.Red; // this.labMessage.Text = "این کاربر پیش از این به سامانه وارد شده است. "; // DialogResult drResult = MessageBox.Show("آیا کاربری که پیش از این وارد شده است خارج و شما وارد شوید؟", "پرسش", MessageBoxButtons.YesNo, MessageBoxIcon.Question, // MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading); // if (drResult == DialogResult.Yes) // { // User.Login(this.cnConnection, ref this.usLogined, this.tbCoId.Text, this.tbPassword.Text); // Employee.GetByCoID(this.cnConnection, this.usLogined.strCoID, this.emLogined); // this.frmManagement.staUser.Text = this.emLogined.strName; // SetApplicationFacilities(); // if (this.CbSaveUserName.Checked) // { // FamSetting.SetLastUserName(this.setSettings.strXmlPath, this.tbCoId.Text); // } // this.frmManagement.menLogIn.Enabled = false; // this.frmManagement.menLogOut.Enabled = true; // this.Close(); // } // break; // case User.AccountStatus.UserOrPassNotCorrect: // this.labMessage.ForeColor = Color.Red; // this.labMessage.Text = "نام کاربری یا گذرواژه اشتباه است."; // break; //} }
private void CbSaveUserName_CheckedChanged(object sender, EventArgs e) { FamSetting.SetSaveUserName(this.setSettings.strXmlPath, this.CbSaveUserName.Checked); }
private void butReport_Click(object sender, EventArgs e) { if (this.lisEmployeesColumns.Count == 0) { MessageBox.Show("هیج ستونی انتخاب نشده است."); return; } EmployeesReport erEmployeesReport = new EmployeesReport(); erEmployeesReport.cnConnection = this.cnConnection; erEmployeesReport.usUser = this.usUser; erEmployeesReport.setSettings = this.setSettings; //Report StiReport srEmployees = new StiReport(); srEmployees.Pages[0].PaperSize = System.Drawing.Printing.PaperKind.A4; //MessageBox.Show(srEmployees.Pages[0].PaperSize.ToString()); //srEmployees. string strSColumnsName = ""; for (int i = 0; i < this.lisEmployeesColumns.Count; i++) { if (i != 0) { strSColumnsName += ", "; } strSColumnsName += this.lisEmployeesColumns[i].strName; } //DataBase StiSqlDatabase dbDataBase1 = new StiSqlDatabase(); dbDataBase1.Alias = "dbDataBase1"; dbDataBase1.Name = "dbDataBase1"; dbDataBase1.ConnectionString = this.cnConnection.strConnectionStringPty; srEmployees.Dictionary.Databases.Add(dbDataBase1); //DataSource StiSqlSource dsDataSource = new StiSqlSource(); dsDataSource.NameInSource = "dbDataBase1"; dsDataSource.Alias = "dsDataSource"; dsDataSource.Name = "dsDataSource"; dsDataSource.SqlCommand = Employee.GetSqlCommand(this.emSearch, strSColumnsName); for (int i = 0; i < this.lisEmployeesColumns.Count; i++) { dsDataSource.Columns.Add(this.lisEmployeesColumns[i].strName, this.lisEmployeesColumns[i].typType); } srEmployees.DataSources.Add(dsDataSource); //HeaderBand StiHeaderBand headerBand1 = new StiHeaderBand(); headerBand1.Height = 0.5; headerBand1.Name = "HeaderBand1"; srEmployees.Pages[0].Components.Add(headerBand1); StiText headerText = new StiText(new RectangleD(5, 0.2, 9.6, 1)); headerText.Text = "کارکنان شرکت " + FamSetting.GetCoInformation(this.cnConnection).strName; headerText.HorAlignment = StiTextHorAlignment.Center; headerText.Name = "headerText1"; headerText.Font = new Font("B Titr", 17); headerText.Brush = new StiSolidBrush(Color.Transparent); headerBand1.Components.Add(headerText); //ColumnHeaderBand StiColumnHeaderBand columnHeaderBand1 = new StiColumnHeaderBand(); columnHeaderBand1.Height = 0.5; columnHeaderBand1.Name = "columnHeaderBand1"; srEmployees.Pages[0].Components.Add(columnHeaderBand1); StiText[] stColumnHeaders = new StiText[this.lisEmployeesColumns.Count]; double douX = 19; for (int i = 0; i < this.lisEmployeesColumns.Count; i++) { stColumnHeaders[i] = new StiText(new RectangleD(douX - this.lisEmployeesColumns[i].douWidth, 1, this.lisEmployeesColumns[i].douWidth, 0.8)); stColumnHeaders[i].Text = this.lisEmployeesColumns[i].strCaption; stColumnHeaders[i].Name = "ch" + this.lisEmployeesColumns[i].strName; stColumnHeaders[i].Border = new StiBorder(StiBorderSides.All, Color.Black, 1, StiPenStyle.Solid); stColumnHeaders[i].Font = new Font("B Titr", 12); stColumnHeaders[i].Brush = new StiSolidBrush(Color.Gray); stColumnHeaders[i].HorAlignment = StiTextHorAlignment.Center; stColumnHeaders[i].VertAlignment = StiVertAlignment.Center; columnHeaderBand1.Components.Add(stColumnHeaders[i]); douX -= this.lisEmployeesColumns[i].douWidth; } //DataBand StiDataBand dataBand1 = new StiDataBand(); dataBand1.DataSourceName = "dsDataSource"; dataBand1.Height = 0.5; dataBand1.Name = "dataBand1"; srEmployees.Pages[0].Components.Add(dataBand1); StiText[] stDataText = new StiText[this.lisEmployeesColumns.Count]; douX = 19; for (int i = 0; i < this.lisEmployeesColumns.Count; i++) { stDataText[i] = new StiText(new RectangleD(douX - this.lisEmployeesColumns[i].douWidth, 0, this.lisEmployeesColumns[i].douWidth, 0.6)); stDataText[i].Text = "{dsDataSource." + this.lisEmployeesColumns[i].strName + "}"; stDataText[i].Name = "db" + this.lisEmployeesColumns[i].strName; stDataText[i].Font = new Font("B Nazanin", 10); stDataText[i].Brush = new StiSolidBrush(Color.Transparent); stDataText[i].HorAlignment = StiTextHorAlignment.Center; stDataText[i].VertAlignment = StiVertAlignment.Center; stDataText[i].Border = new StiBorder(StiBorderSides.All, Color.Black, 1, StiPenStyle.Solid); dataBand1.Components.Add(stDataText[i]); douX -= this.lisEmployeesColumns[i].douWidth; } //Render srEmployees.Dictionary.Synchronize(); srEmployees.Compile(); srEmployees.Render(false); //srEmployees.Save(@"c:\rpt\report3.mrt"); erEmployeesReport.stvEmployees.Report = srEmployees; erEmployeesReport.ShowDialog(); }