예제 #1
0
        private void PrintAddress(String OpId)
        {
            Funkcii      f      = new Funkcii();
            DatabaseConn dbc    = new DatabaseConn();
            String       Adresa = Vasko.ExecuteScalar("SELECT ServicerContact FROM Service WHERE ServiceID=" + OpId);

            Adresa = Adresa.Substring(Adresa.IndexOf("ul"));
            Adresa = Adresa.Substring(0, Adresa.IndexOf("www"));
            String Datum = DateTime.Now.ToShortDateString();

            f.PrintWord(dbc.TemplatePath() + @"\IT_Servicer_Address.dot",
                        "SELECT i.ProductGroup, i.Description, i.SerialNumber, s.Servicer, '" + Adresa + "' as Address, s.Problem FROM Service as s LEFT OUTER JOIN Items as i ON i.ItemId=s.ItemId WHERE s.ServiceID=" + OpId, "");
        }
예제 #2
0
        private void tbReprint_Click(object sender, EventArgs e)
        {
            if (tbAssignementNumber.Text.Length > 0)
            {
                PleaseWait frmPW = new PleaseWait();
                frmPW.Show();
                Application.DoEvents();

                String Selected             = "";
                String SelectedAssignements = "";
                String Assigned             = "";
                String OdbranTip            = "";

                String AssignementId = Vasko.ExecuteScalar("SELECT AssignementId FROM Assignement WHERE AssignementNumber = '" + tbAssignementNumber.Text + "'");
                if (AssignementId != "")
                {
                    String Tip = Vasko.ExecuteScalar("SELECT [Type] FROM Assignement WHERE AssignementID=" + AssignementId);
                    if (Tip == "1")
                    {
                        OdbranTip = "IT_Assignement_Form.dot";
                    }
                    else if (Tip == "2")
                    {
                        OdbranTip = "IT_Temporary_Form.dot";
                    }
                    else if (Tip == "3")
                    {
                        OdbranTip = "IT_Returning_Form.dot";
                    }

                    DataTable dt = new DataTable();
                    dt = Vasko.ReturnDataTable("SELECT ItemId FROM Assignement_Item WHERE AssignementId = " + AssignementId);

                    foreach (DataRow drow in dt.Rows)
                    {
                        if (Selected != "")
                        {
                            Selected += ",";
                        }
                        Selected += drow[0].ToString();
                    }

                    if (SelectedAssignements != "")
                    {
                        SelectedAssignements += ",";
                    }
                    {
                        if (!SelectedAssignements.Contains(AssignementId))
                        {
                            SelectedAssignements += AssignementId;
                        }
                    }

                    Funkcii      f               = new Funkcii();
                    DatabaseConn dbc             = new DatabaseConn();
                    string[]     AllAssignements = SelectedAssignements.Split(',');
                    foreach (string str in AllAssignements)
                    {
                        String SqlPrint  = @"SELECT AssignementTo as AssignedTo, AssignementNumber, AssignedBy, Format(AssignedOnDate, 'dd.MM.yyyy') as AssignedOn FROM Assignement WHERE AssignementId=" + str + "; ";
                        String SqlPrint2 = @"SELECT ProductGroup, Description, DMMPropertyNum, SerialNumber, Quantity FROM Items WHERE ItemId IN (" + Selected + ") ";
                        f.PrintWord(dbc.TemplatePath() + @"\" + OdbranTip, SqlPrint, SqlPrint2);
                    }
                }
                else
                {
                    MessageBox.Show("There is no assignment form as the entered number!", "Not exists!", MessageBoxButtons.OK);
                }
                frmPW.Close();
            }
        }
예제 #3
0
        private void PrintForm(String TemplateForm, String Type)
        {
            if (outlookGrid1.SelectedRows.Count > 0)
            {
                PleaseWait frmPW = new PleaseWait();
                frmPW.Show();
                Application.DoEvents();

                String Selected             = "";
                String SelectedAssignements = "";
                String Assigned             = "";
                String OdbranTip            = "";

                foreach (DataGridViewRow dr in outlookGrid1.Rows)
                {
                    if (dr.Selected && dr.Index > 0)
                    {
                        //if (dr.Cells["Assignement Form"].Value.ToString() != "")
                        String AssId = Vasko.ExecuteScalar("SELECT AssignementId FROM Items WHERE ItemID=" + dr.Cells["ItemID"].Value.ToString());
                        if (AssId != "")
                        {
                            String Tip = Vasko.ExecuteScalar("SELECT [Type] FROM Assignement WHERE AssignementID=" + AssId);//dr.Cells["AssignementId"].Value.ToString());
                            if (Tip == "1")
                            {
                                OdbranTip = "Assignement Form";
                            }
                            else if (Tip == "2")
                            {
                                OdbranTip = "Temporary Form";
                            }
                            else if (Tip == "3")
                            {
                                OdbranTip = "Return Form";
                            }

                            if (Tip != Type)
                            {
                                goto error2;
                            }
                            else
                            {
                                DataTable dt = new DataTable();
                                dt = Vasko.ReturnDataTable("SELECT ItemId FROM Assignement_Item WHERE AssignementId = " + AssId); //dr.Cells["AssignementId"].Value.ToString());
                                foreach (DataRow drow in dt.Rows)
                                {
                                    if (Selected != "")
                                    {
                                        Selected += ",";
                                    }
                                    Selected += drow[0].ToString();
                                }
                            }

                            if (SelectedAssignements != "")
                            {
                                SelectedAssignements += ",";
                            }
                            {
                                if (!SelectedAssignements.Contains(AssId)) //dr.Cells["AssignementId"].Value.ToString()))
                                {
                                    SelectedAssignements += AssId;         // dr.Cells["AssignementId"].Value.ToString();
                                }
                            }
                        }
                        else
                        {
                            goto error;
                        }
                        goto stop;
                    }
                }
stop:
                Funkcii f = new Funkcii();
                DatabaseConn dbc             = new DatabaseConn();
                string[]     AllAssignements = SelectedAssignements.Split(',');
                foreach (string str in AllAssignements)
                {
                    String SqlPrint = "";
                    if (Type == "3")
                    {
                        SqlPrint = @"SELECT AssignementReturnPerson as AssignedTo, AssignementNumber, AssignedBy, Format(AssignedOnDate, 'dd.MM.yyyy') as AssignedOn FROM Assignement WHERE AssignementId=" + str + "; ";
                    }
                    else
                    {
                        SqlPrint = @"SELECT AssignementTo as AssignedTo, AssignementNumber, AssignedBy, Format(AssignedOnDate, 'dd.MM.yyyy') as AssignedOn FROM Assignement WHERE AssignementId=" + str + "; ";
                    }
                    String SqlPrint2 = @"SELECT ProductGroup, Description, DMMPropertyNum, SerialNumber, Quantity FROM Items WHERE ItemId IN (" + Selected + ") ";
                    f.PrintWord(dbc.TemplatePath() + @"\" + TemplateForm, SqlPrint, SqlPrint2);
                }
                goto end;

                error  : MessageBox.Show("One of selected items doesn't has a created form! Please create a form first, and after that try to print it!", "Error!", MessageBoxButtons.OK); goto end;
                error2 : MessageBox.Show("One of selected items doesn't have created this type of form! You can print just: " + OdbranTip + "!", "Error!", MessageBoxButtons.OK); goto end;
                end    : ExecuteSearch();

                frmPW.Close();
            }
        }